I would like to send an email from my Gmail account using python so when i have an error ill receive an auto email. At current the program handles the errors internally and keeps trying to do its task. That part is fine but when it hits an error I would like to receive an email. So i did some googling and found this nice script
Expand|Select|Wrap|Line Numbers
- import smtplib
- fromaddr = 'my email'
- toaddrs = 'to my email'
- msg = 'Test Email message'
- #provide gmail user name and password
- username = 'username'
- password = 'password'
- # functions to send an email
- server = smtplib.SMTP('smtp.googlemail.com:465')
- server.ehlo()
- server.starttls()
- server.ehlo()
- server.login(username,password)
- server.sendmail(fromaddr, toaddrs, msg)
- server.quit()
Expand|Select|Wrap|Line Numbers
- Traceback (most recent call last):
- File "C:\email.py", line 1, in <module>
- import smtplib
- File "C:\Python27\lib\smtplib.py", line 46, in <module>
- import email.utils
- File "C:\email.py", line 11, in <module>
- server = smtplib.SMTP('smtp.googlemail.com:465')
- AttributeError: 'module' object has no attribute 'SMTP'
Can anyone help ?
Cheers Shane
P.s using winblows