[Python] Send Mail by my gmail account
by 담배맛구마To do. : Get My IP(private) and Send mail by gmail.
import os
import smtplib
from email.mime.text import MIMEText
#GET My IP And Save it textfile
os.system("ip addr show eth0 | grep inet > textfile")
# textfile to MIME Type
fp = open("textfile", 'rb')
msg = MIMEText(fp.read())
fp.close()
msg['Subject'] = "I'm Odroid. Tell you Fukcing my Addr."
msg['From'] = "MY_GMAIL_ACCOUNT"
msg['To'] = "RECEIVER"
s = smtplib.SMTP_SSL('smtp.gmail.com',465)
s.login("MY_GMAIL_ACCOUNT", "GMAIL_PASSWD")
s.sendmail("MY_GMAIL_ACCOUNT", "RECEIVER", msg.as_string())
s.quit()
Do not work!?
ERROR
Traceback (most recent call last):
File "sendmail.py", line 23, in module
s.login("MY_GMAIL_ACCOUNT", "GMAIL_PASSWD")
File "/usr/lib/python2.7/smtplib.py", line 622, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, '5.7.14 ...
Please log in via your web browser and 5.7.14 then try again. 5.7.14 Learn more at 5.7.14 https://support.google.com/mail/answer/78754 q27sm14448288pfi.80 - gsmtp')
i) Unlock Captcha : https://accounts.google.com/DisplayUnlockCaptcha
ii) Change Security Option : https://www.google.com/settings/security/lesssecureapps
반응형
'Dev-' 카테고리의 다른 글
[Python] Geoip를 통한 IP 별 국가코드 매칭 (2) | 2016.07.09 |
---|---|
[Python] PyQT4 ComboBox와 TableWidget 제어 (0) | 2016.04.09 |
[Python] PyQT5 기본템플릿비교(Widget, Dialog, Main Window) (0) | 2015.11.14 |
[Python] PyQT5 시작하기 (6) | 2015.10.26 |
[Python] Log Gathering (0) | 2015.10.23 |
블로그의 정보
정윤상이다.
담배맛구마