I'm trying to send an e-mail with sendmail
, but I need to specify some headers (From, Content-Type, Subject). Here is the command I am currently running:
echo "Content-Type: text/plain\r\nFrom: do-not-reply@mydomain.com\r\nSubject: Test\r\n\r\nThe body goes here" | sendmail -f do-not-reply@mydomain.com admin@mydomain.com
The problem is that the headers are not being set. Do I have the format correct?
Best Answer
You need to use
echo
with the 'e' parameter.If you look at the result of sending mail with your command you see the following:
(It literally shows up as above as a single line, including the 'special characters')
Applying the above, slight, modification allows your code to work fine: