Simple Email

Python

Public Domain

Send's text email without attachments via SMTP

Download (right click, save as, rename as appropriate)

Embed

Tags:

mail python smtp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def simpleMail(serverURL=None, sender='', to='', subject='', text=''):
    """
    Usage:
    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)
    mailServer.quit()