Python command-line script for sending email and doing mail-merge.
MailViaServer3 [-h HELO_HOST ] [-f MAIL_FROM] -F -R -s {|-} [ ...]
Mails [file] (or standard in) to mail address <addr>
through the mail server given by -s <server>, or writes
email to standard out.
Options:
-h HELO Name of host passed in SMTP HELO command. Default is "localhost".
-f FROM Return addressed passwd in SMTP MAIL FROM command. Default is "jon@localhost".
-A FILE Read addresses from FILE. One address per line, blank lines and comments (#) are ignored.
-F FINDSTR Find FINDSTR in and repace with REPSTR below. Both -F and -R can be repeated multiple times.
-R REPSTR See -F above
-s SERVER Send email via mail server SERVER. If none given, email is formatted and sent to standard out. This is useful for testing.
-t FILE Use StartTLS on port 587. Will read email account name from first line, and password from second line, of FILE.
-T Use StartTLS on port 587. Will prompt user for account and password.
-v Display progress
Example:
MailViaServer3 reads an email template from standard input (it uses standard input because the hyphen '-' is used instead of a file name).
The example uses the -F and -R options to substitute the value of {NAME} in the template. The email is mailed to the addresss b.jones@example.com by sending it to the email server smtp.myplace.edu.
The FROM address submitted to the email server is smith@myplace.edu. Note that this FROM address is not the same as the From: address used inside the email template.
$ MailViaServer3 -f smith@myplace.edu -s smtp.myplace.edu -F{NAME} -RJohnboy - b.jones@example.com <<EOM
> Subject: This is a test message.
> From: Another.place@another.time.com
>
> Hi there {NAME}
> EOM