sendmail: specify SMTP server and TLS options per message

1.4k Views Asked by At

I need to send emails form a script where the SMTP I want to send by varies per message. Using mailx, one may specify the SMTP server, TLS options, username, and password on the command line. However, I need to send embedded HTML emails (not as attachment), and mailx does not support that, according to various posts I've found and time spent pulling my hair out trying to get it to work. On the other hand, with sendmail I can send embedded HTML, but it seems the SMTP server options have to be in a config file, and I don't know how to override them from the command line. So how do I send embedded HTML while specifying custom SMTP options?

1

There are 1 best solutions below

0
On

I gather you're looking for a low-level solution, but this is so straightforward in Python that I think it's worth exploring. There are several examples of literally exactly what you're trying to do right here in the documentation.

I also answered a similar question here.

Even if you're unfamiliar with Python, those docs pages pretty much spell out the whole program for you.