Append Signature When Invoking Mutt via Command Line - signature

I looked everywhere, but could not find an answer. When I invoke mutt via a script or via a simple cmd line entry (see below), the signature never gets appended. Is it possible to do this? When I compose an email via the mutt gui it works fine. :{
echo "TEST" | mutt -s "TEST SIG 1" user#example.com

This is kind of a hack.
mutt -s "message subject" user#example.com < /path/to/message < /path/to/signature

Related

How to execute shell command by mailx

I am using mailx in linux to send mail. Now i want to execute some shell command and paste the output in body of mail
For example i want to send date from linux in mail body
I tried below but that doesnt seems working
mailx -S smtp=$smtpip < date

Command that outputs script results into a text file then emails results to personal email

I am writing a bash script that outputs server status results and want to have a way for it to put the results into a text file then email it to an email entered depending on user input. How would I go about doing this?
Thanks for the help!
to output the results to a file, use the >> or > to at the end of your command followed by a file name.
>> will append to the file. Which means the previous content of your file will remain intact.
> will remove everything and create a file with the new ouput.
for eg:
echo $serverOutput>output.txt
now to mail it :
read email // will read the email address of the user.
to mail:
uuencode output.txt output.txt|mailx -s "server output" $email
your file will be sent as an attachment.
Is this what you require?
Creating a cron job would be another task. But for your initial question about having the serverStatus inside a text file and then mail that to the user's email. Below is an example:
say we use "ps -ef|grep processname" command. replace "top" with the command you have.
ssh -q username#serverName "ps -ef|grep -i process">>output.txt
echo "enter email:"
read email
uuencode output.txt output.txt|mailx -s "serverStatusReport" $email
if you have any script/template which needs to be given this functionality, please share the code or elaborate a bit.
Regarding the cron job you would need to include the command/script in the crontab file along with the time you want it to schedule.
for eg:
echo "* * * * * /path/to/your/script.sh ">>crontab
Hope this gives you a path forward on your task

How do you pull text out of a file and Email it as the body in Redhat?

We have another piece of software saving data into an rtf file. We need to pull that data out and email it as the body of the Email. In SCO Unix we were able to use this:
mailx –s “Subject of email” email#example.com </text.rtf
But now that we are running Redhat the mailx package used is an entirely different package and will only attach the file as an attachment. Any help on this subject is greatly appreciated.
We had a similar problem and solved it by faking mailx by a shell script. Change $PATH so that your "mailx" shell script is found first.
In this script we use sendEmail (Perl script, look here http://caspian.dotconf.net/menu/Software/SendEmail/) to send the mail:
sendEmail $ABSAUTH $(echo \-u "$(echo "$1"|sed -e 's/^-s//')") -t $2
We ended up using the mail command instead.
$ mail –s “Subject of email” email#example.com < /text.rtf
some documentation can be found at https://www.binarytides.com/linux-mail-command-examples/ or using the "man mail" command.

How do I send email from linux terminal, with contents of multiple files as the mail-body?

I am aware that I can use the following command from my linux terminal to send an email:
sendmail user#example.com < file1.text
This command will basically send the contents of the file1.text as mail body.
But how can I add contents of multiple files inside mail body using the same command?
I tried the following which obviously did not work:
sendmail user#example.com < file1.text,file2.text
Use the cat command. cat is short for "concatenate"; it will concatenate all the files given on the command line. Then pipe the output to sendmail:
cat file1.text file2.text | sendmail user#example.com

How to program Mutt to take an action upon new email arriving?

There is an option beep_new in the Mutt's configuration variables, which causes Mutt to issue a beep when new email arrives. Also there is <shell_esc> command, which executes a command in internal shell. Is there a way to cause Mutt to execute some user defined action (shell command) when new email arrives? Maybe <pipe-message> can help? (One can use <pipe-message> in a configuration file to call a shell command. Is there a way to do this in running Mutt?)
EDIT: as per Glenn advice, a script from Mutt can be called by configuring the custom status format in the .muttrc file:
set status_format="/some/script.sh '%r %f (%L) |"
But I can't figure out how to use this for new email detection, since the "New mail in..." notification appears on the command line, and not in the status line. And if the email arrived to a mailbox that is not the current, then the status line doesn't change at all.
EDIT 2: OK, the %b variable in the status_format did the thing.
Mutt can't do this (at least not without some workaround).
NeoMutt can: see it's new_mail_command.
You can achieve that through inotifywait as the mutt manual suggests.
Install inotify
(example for Debian based distros: apt install inotify-tools)
Watch mutt folder and run your script
(bash script example:
while : ; do inotifywait -e modify -r ~/.mutt ; /my_facy/script ; done

Resources