what is the syntax for sending a subject ?
sendmail -t a@b.com
The person receives the mail with an empty subject!
the man pages dont give anything related to subject...anybody??
what is the syntax for sending a subject ?
sendmail -t a@b.com
The person receives the mail with an empty subject!
the man pages dont give anything related to subject...anybody??
Hi When i use the syntax given in the site ..i get a ">" after executing the below line
When i type the below and hit enter
cat <<content | sendmail -t a@b.com
I get this
cat <<content | sendmail -t a@b.com
>
and when i type in
cat <<content | sendmail -F Me -t a@b.com
>Subject:hello
I am getting the mail with the subject hello
but how do we input the subject using a script?
I am already using mail -s but the problem is it doesnt allow us to mention a from address
If you have mailx installed, you can use the -r option.
Else...
$ SUBJECT="Testing some mail stuff"
$ cat << EoF | /usr/lib/sendmail -F me@here.com -t you@there.com
> Subject: $SUBJECT
> Testing stuff
> EoF
Cheers
ZB
I know this works when you type this in the command prompt..I can type my own body and its done..
My concern being the same cannot be reproduced if I put this in a script and want the body contents to be taken from a file
I have the contents in a file named text
And each time i execute the script sendmail should a send a mail with subject:testing and the contents from the file text
echo "Subject: Testing" | cat - text | /usr/lib/sendmail -F me@here.com -t you@there.com
Cheers
ZB
Why didnt i think of this
Working Gr8! Thanks!
Thanks dude I was also looking for something like this!!!
Can you tell me why its this "cat - text" It didn't work without the "-" The subject was empty. Sorry I might be asking a dumb question...
Sure.
The "-" is a synonym for STDIN - standard input. So what we're saying here is conCATenate STDIN (in our case, the echo command) and the "text" input file, then pipe everything through to sendmail.
e.g.
$ echo "foo" | cat - /etc/hosts
foo
192.168.0.1 host1
192.168.0.2 host2
Cheers
ZB
You can also use the following syntax (tested whith ksh) :
{ echo "Subject: Testing" ; cat text ;} | /usr/lib/sendmail -F me@here.com -t you@there.com
Jean-Pierre.
Or:
sendmail -f me@here.com -t\
< <(printf "%s\n" "To: you@there.com" \
"Subject: Testing" "$(<inputfile)")
P.S. Use pipe if your shell doesn't support process substitution:
printf "%s\n" "To: you@there.com" \
"Subject: Testing" "$(<file)"\
|sendmail -f me@here.com -t