The b(ack)log

Sending email using SMTP and TLS from the command line

Here is a script you can use to send email from a linux command line if you need to use TLS (Transport Layer Security).

import smtplib
server = smtplib.SMTP('')
server.login('username', 'password')
msg = "Subject: Test\r\nFrom:\r\nTo:\r\n\r\nThis is a test\r\n"
server.sendmail('', '', msg)

Copy and paste this into a file and run it using python: python

I had to test SMTP credentials without installing a mail client (or something worse…), so the script is pretty basic.