Over a million developers have joined DZone.

Send An Email From Python

DZone's Guide to

Send An Email From Python

· ·
Free Resource
// description of your code here
Not sure where I got this from, but it does its job. Sends a simple smtp email message in python.

import smtplib
def mail(serverURL=None, sender='', to='', subject='', text=''):
    mail('somemailserver.com', 'me@example.com', 'someone@example.com', 'test', 'This is a test')
    headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (sender, to, subject)
    message = headers + text
    mailServer = smtplib.SMTP(serverURL)
    mailServer.sendmail(sender, to, message)

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}