This example demonstrates how to set up and send an email from a Python script using JangoSMTP. Download the source code for this example, insert your own JangoSMTP username/password/etc and start sending tracked emails today!
# create the message object msg = MIMEMultipart('alternative') msg['Subject'] = "JangoSMTP from Python Test" msg['From'] = FromAddress msg['To'] = ToAddress # Create a plain-text and an HTML version of the message text = "This is a plain text email sent from a python program!" html = """\ <html> <head></head> <body> <p> This is an html email sent from a <b>python</b> program! </p> </body> </html> """ # JangoSMTP credentials username = "Your JangoSMTP Username" password = "Your JangoSMTP Password" # store both parts of the email part1 = MIMEText(text, 'plain') part2 = MIMEText(html, 'html') # Attach parts into message container. msg.attach(part1) msg.attach(part2) # Open a connection to the JangoSMTP server s = smtplib.SMTP('relay.jangosmtp.net', 25) # Authenticate s.login(username, password) # send the email s.sendmail(FromAddress, ToAddress, msg.as_string())