Posts

program to send emails using python

                 Program to send emails using python Source Code: ''' import smtplib import config connection=smtplib.SMTP('smtp.gmail.com',587) connection.ehlo() connection.starttls() connection.ehlo() connection.login('xyz@gmail.com','ur password') connection.sendmail('xyz@gmail.com','pqr@gmail.com',' hello python here:::::::;') connection.quit() ''' import smtplib sender = 'xyz.com' receivers = ['pqr@gmail.com'] message = """From: From Person <from@fromdomain.com> To: To Person <to@todomain.com> Subject: SMTP e-mail test This is a test e-mail message. """ try:    smtpObj = smtplib.SMTP('localhost')    smtpObj.sendmail(sender, receivers, message)             print ("Successfully sent email") except SMTPException:    print ("Error: unable to send email")