In a Python program, there is no advantage.
The only purpose of ssmtp is to wrap the SMTP protocol in the sendmail API. That is, it provides a program /usr/sbin/sendmail
that accepts the same options, arguments, and inputs as the full-blown sendmail (though most of the options do nothing); but behind the scenes, instead of processing the email itself, it sends the message to an SMTP server. This is for systems that need to have a sendmail
program present, perhaps because they don't understand SMTP - for example, I think older versions of PHP had this requirement, and even in recent versions it might still be easier to configure PHP to use the so-called sendmail interface (i.e. the program sendmail
) than to use SMTP directly. (I haven't used PHP in a little while, I'm not sure about the current status)
However, in Python the situation is reversed: you have a builtin library that makes it easy to use SMTP directly, whereas using sendmail
requires you to invoke the subprocess
module which is somewhat clunky and also very dependent on things that are not part of Python. So basically there is no reason not to use smtplib
.