LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sendmail from the command line (https://www.linuxquestions.org/questions/linux-newbie-8/sendmail-from-the-command-line-288920/)

Draithon 02-11-2005 09:04 AM

Sendmail from the command line
 
I am trying to figure out how I can append a subject to sendmail from the command line. I am using RH Enterprise.

using bash shell

sendmail -f"from name" "recipient" <"file"

that sends the mail but no subject.

I have tried this as well

mail -s"Subject header" "recipient" <"file"

But that will not allow me to change the from address. It send it saying root, when I am trying to mask that.

any suggestions would be greatly appreciated.

thanks. back to :study:

david_ross 02-11-2005 01:24 PM

You should be able to read in a file like the following into "sendmail -t"
Code:

to:recipient@somewhere.com
from:you@yourdomain.com
subject:Testing 123

This is my message.


Draithon 02-11-2005 02:23 PM

I am sending a log file that I created, so I will have to try to format the log file in a manner that corresponds with your advice and see if that gives me what I am looking for.

david_ross 02-13-2005 12:57 PM

I haven't tried this but you should be able to do it with 2 files, one being the static header and the other being the log:
cat header.txt file.log | sendmail -t

Just remember to have the extra newline at the bottom of the header file.

RichardBronosky 05-04-2009 01:27 PM

Quote:

Originally Posted by david_ross (Post 1468700)
I haven't tried this but you should be able to do it with 2 files

No need to create the 2nd file. That is what heredoc is for.

Code:

cat - file.log << EOF | sendmail -t
to:recipient@somewhere.com
from:you@yourdomain.com
subject:Testing 123

EOF

Lots of POSIX apps read stdin as the contents for argument/filename "-"

Ever done: grep Error | vim -
Same concept combined with a little extra bash-fu

anandhavalli 04-14-2011 03:57 AM

sendmail configuration
 
I am in need of configuration settings and steps for sending mails from linux server to some other domain or network.
I need to send mail from linux system to my mail id.Please help me out in doing the same.


All times are GMT -5. The time now is 02:45 AM.