Super User Asked by Robby75 on January 1, 2022
I can use
echo "My Mail content" | exim [email protected]
to send an email, but it does not contain a subject for the message
How can I send an email with subject, “From” and “Reply-To” Headers from the command-line in exim?
exim -i -t <<< 'From: My Self <[email protected]>
To: Recip One <[email protected]>, Recip Two <[email protected]>
Subject: Test message
content line 1
content line 2'
This works for any sendmail-compatible MTA not just exim. If you have sendmail you could run same command but start with "sendmail -i -t...".
Of course you could load the input from a text file instead.
exim -i -t < file/path.txt
Quotes are not needed for label part of email addresses before angle backets.
-i switch prevents dot-line-termination. If you just run "exim -t" and paste or type in the content interactively then skip the -i switch and you can end with line containing just dot then a blank line (don't know why the extra blank line is needed--it didn't used to be).
-t derives recipients from the content you give rather than specifying as command-line parameter. Email agents expect To: field to be set and honor labels, so you should normally send it. If you do send a To: then use -t switch because specifying recipients on command line would be redundant and a source of possible conflict in that case.
Another tactic is to use s-nail's mailx program. With s-nail installed, just add "set mta=/usr/bin/exim" (or /usr/sbin/exim or wherever it resides) to /etc/mail.rc or your personal ~/.mailrc and use mailx like so:
mailx -s 'subject line' 'Recip One <[email protected]>' 'Recip Two <[email protected]>' <<< 'content line 1
content line 2'
or
mailx -s 'subject line' 'Recip One <[email protected]>' 'Recip Two <[email protected]>' < file/path.txt
Mailx has a nice -a switch for adding file attachments. If you're running a very old version of s-nail, there is no 'mta' setting and you need to replace /usr/sbin/sendmail or /usr/bin/sendmail (or similar) with a sym link to your exim binary.
Answered by user306125 on January 1, 2022
Exim expects to receive a full RFC 5322 / 2822 / 822 email message as input. So you need to give the headers in the form of... headers.
$ (echo "To: [email protected]"; echo "Reply-To: [email protected]" echo "Subject: Hello!"; echo ""; echo "My Mail Content") | sendmail [email protected]
$ sendmail [email protected] <<'EOF' From: "The Great Quux" <[email protected]> To: "Fred Foobar" <[email protected]> Reply-To: [email protected] Subject: Hello! Content-Type: text/plain; charset=utf-8 My Mail Content EOF
(Not sure if the names in From/To have to be quoted. RFC 5322 seems to say that they should)
Answered by user1686 on January 1, 2022
8 Asked on February 24, 2021 by jason-r-coombs
0 Asked on February 24, 2021 by ijustwantmymousetowork
drivers hardware detection logitech mouse windows 10 wireless mouse
1 Asked on February 24, 2021 by anish-sharma
0 Asked on February 24, 2021 by vinh-ton
1 Asked on February 23, 2021 by ossoso
0 Asked on February 23, 2021 by e_blue
0 Asked on February 23, 2021 by cclloyd
0 Asked on February 22, 2021 by hery
1 Asked on February 22, 2021 by magox
0 Asked on February 22, 2021 by kapad
1 Asked on February 22, 2021 by gunasekaran-s
2 Asked on February 22, 2021 by scott-severance
1 Asked on February 22, 2021 by shobhit-tewari
5 Asked on February 22, 2021 by ramzi-kahil
0 Asked on February 22, 2021 by dor00012
0 Asked on February 21, 2021
1 Asked on February 21, 2021 by ricardo3889
1 Asked on February 20, 2021 by micjaakson
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir