email - Python : sending mail through gmail issue -
I'm trying to send an email (via Gmail) using a Python script that someone once Written on this site, but I am getting an error: Unicodecode error: 'utf8' can not decode byte 0xe8 in codec condition 2: invalid continuity byte
script:
import imported smtplib email.mime text import MIMEText # mail setup FROMMAIL = "xxx@gmail.com" LOGIN = FROMMAIL PASSWORD = "yyy" SUBJECT = "test topic" TOMAIL = "x Xx@gmail.com "msg = MIMEText ('testcontent') msg [subject] '=' test 'msg [from'] = FoMMM msg ['to'] = tommail server = smartplay MTP ('smtp.gmail.com', 587) server.set_developleval (1) server.hello () server.starttls () server.login (login, password) server.sendmail (FROMMAIL, [TOMAIL], msg.as_string (): Server.quit () stacktrace:
traceback (most recent call final): File "C: \ user \ Xxx \ desktop \ test.py ", line 11, server = smtplib.SMTP ('smtp.gmail.com', 587) file" C: \ program files \ Python31 \ lib \ Smtplib.py ", line 248, __init__ fqdn In the = socket.getfqdn () file, type "C: \ Program Files \ Python31 \ lib \ socket.py", line 290, getfqdn name = gethostname (), Unicode Odarrr: 'utf8' codec situation can not decode byte 0xe8 2: Invalid continuation bytesI'm using Python v3.1.3. How to solve it?
Thank you.
Use the 'Email' module to generate the right formatted email directly through Python's Python While making e-mail, handling the issue of encoding at the application level, it is not the way to go.
Comments
Post a Comment