Jakob
Jakob

Reputation: 268

send mail from linux command line using bcc and from headers

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:

Thanks for any input.

Upvotes: 3

Views: 4639

Answers (3)

benaki
benaki

Reputation: 1

mail -S smtp=localhost -s 'your subject' -b your@bcc,other@bccreip [email protected] < "body of email"

Upvotes: -2

etaion
etaion

Reputation: 36

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.

Upvotes: 2

This question and this one seems quite related to yours (at least if you want to code a command-line program which may send emails)

You could use libsmtp, libesmtp, libvmime etc.

And many scripting languages (Python, Ruby, Perl, ...) have several mail sending facilities.

On Debian, the mime-construct command is able to send a message in BCC, and you can find many other mailing utilities.

Upvotes: 1

Related Questions