BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Tuesday, September 7, 2010

SMTP Email Delivery

Here is some basic code that allows you to send an email using python, which of course can then be called from MEL.

def basicEmail(fromAddr,toAddr,subject,messageBody,debug=False):
import smtplib
toList = toAddr
if type(toAddr) == list:
toList = ', '.join(toAddr) # this is a single string ,separated list of the to: adresses
mail = ('From: '+fromAddr+'\r\nTo: '+toList+'\r\nSubject: '+subject+'\r\n'+messageBody)
server = smtplib.SMTP('mail.jacobschieck.com')
server.set_debuglevel(debug)
server.login('pym***@jacobschieck.com', 'pym***')
server.sendmail(fromAddr,toAddr,mail)
print "Successfully sent email"
server.quit()

basicEmail('jschieck@gmail.com','jschieck@gmail.com',' test','this is the msg body')

0 comments: