import smtplib from email.mime.text import MIMEText as text def send_email(sender,receiver,message,subject) : sender = sender receiver = receiver m = text(message) m['Subject'] = subject m['From'] = sender m['To'] = receiver try : smtpObj = smtplib.SMTP('localhost') smtpObj.sendmail(sender, receiver, str(m)) print "Successfully sent email." except SMTPException : print "Error! Unable to send email..."