Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send mail from linux command line using bcc and from headers [duplicate]

I would like to send (batch) emails from a linux (ubuntu, postfix) command line.

I would like to include a bcc header (that actually sends the mail to this address), and I would like to give a from: address.

I do not need attachments, text only. However, unicode support would be nice (not essential). I would like a solution that is simple and robust (less important: will works on other machines/MTAs as well)

So far I tried:

  • sendmail. This works great, but the BCC headier is ignored (which might be a postfix setting? I would not want to modify my postfix settings...
  • mutt. can be used via command line, but then you have to create an own muttrc for the from: header, and there you might have to change some other settings too; again this does not seem very simple or robust.
  • the old "mail" command does not seem to work as expected in newer versions, at least the one I get on ubunto does not recognice the -b (bcc) option.

Thanks for any input.

like image 426
Jakob Avatar asked Jun 23 '26 08:06

Jakob


1 Answers

If you have a local mail server running (exim, sendmail, ...) you can pipe a full, properly formatted message into it and it will be delivered. You must have a complete set of header (From:, To:, Cc:, Date: ...), there must be a blank line after the headers and before the message text, e.g.

exim -t -i < fullyFormattedMessage.txt

Most mailservers will pretend to be sendmail and will accept the -t flag.

like image 99
etaion Avatar answered Jun 25 '26 22:06

etaion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!