I'm trying to send and email including Arabic and Persian characters, using smtplib. The Following is my Function:
def send_email (admin, pwd, user, message):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(admin, pwd)
server.sendmail(admin, user, message)
server.close()
return True
send_email('sender@example.com', 'example', 'reciever@example.com', 'کاراکتر فارسی و عربی Persian and Arabic Characters')
and, I get the following error:
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Any ideas on how to fix it?