I wrote a little Python program in which I send e-mails to recepients from .csv file.
import csv
import smtplib
f = open('output.csv')
csv_f = csv.reader(f)
email=[]
for row in csv_f:
if row:
email.append(row[2])
fromaddr = MY MAIL
toaddrs = email
subject = 'Čestitamo!'
text = 'ččšpšžćčđšđ'
msg = 'Subject: %s\n\n%s' % (subject, text)
username = MY_USER
password = MY_PASS
try:
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, email, msg)
server.quit()
print('Mail sent!')
except Exception as e:
print("ERROR!")
print(e)
Program like this gives error: 'ascii' codec can't encode character '\u010c' in position 9: ordinal not in range
Tried to encode as utf-8, the mail is sent, but i get this:
Äestitamo! ÄÄÅ¡pšžćÄđšđ
Then i tried to decode that on many ways, but i couldn't get proper Croatian letters č,ć,ž,š,đ.
What should I do so i can have proper croatian letters on send mail?
EDIT
changed a line to:
server.sendmail(fromaddr, email, msg.encode("windows-1250"))
now i have š and ž correct!
for č i've got è, for ć i've got æ, for đ i've got ð