Tutorial :how to send email in python


import smtplib    SERVER = "localhost"    FROM = "sender@example.com"  TO = ["user@example.com"]    SUBJECT = "Hello!"    TEXT = "This message was sent with Python's smtplib."  server = smtplib.SMTP(SERVER)  server.sendmail(FROM, TO, message)  server.quit()  

This is giving the error:

'**The debugged program raised the exception unhandled AttributeError  "'module' object has no attribute 'SMTP'"  File: /home/an/Desktop/email.py, Line: 13**'  


Rename your file to something other than email.py. Also get rid of any email.pyc file left over. Problem solved.


This happens because email is a built-in library that comes standard with python. If you rename your program to something else (as suggested above), that should do the trick.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »