.

[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

반응형

블로그의 정보

정윤상이다.

담배맛구마

활동하기