Purpose: you need to send a letter to the mail. The letter has Cyrillic symbols.
The problem: the script works with Latin symbols, but does not work with the Cyrillic alphabet
script:
Import smtplibtext = \ to = 'xxxxxx@gmail.com' subject = 'xxxx' # gmail sign in gmail_sender = 'xxxx@gmail.com' gmail_passwd = 'xxxxxx' server = sMTPLIB.smtp ( '' "smtp.gmail.com ' span>, 587 ) server.ehlo () server.starttls () server.login (gmail_sender, gmail_passwd) body = '\ r \ n' .join ([ 'to: % S' class = ""> '' , text]) try : server.sendmail (gmail_sender, body) print ) except : print (' 'Error Sending Mail ') server.quit () error:
Traceback (Most Recent Call Last): : ) File "" C: /users/babai/pycharmprojects/mail.py "" , line 47 , in & lt; module & gt; server.sendmail (gmail_sender, [to], body) file , line 854 , 'ascii' ) unicodeencodeerror: 'ascii' codec Can '' '' t enterode Characters in Position 63-74: Ordinal Not in Range (128) as I understand the problem of encoding. That is, the SMTPLIB module works only with ANSII ??
question@mail.ru
·