I have a little python script that pulls emails from a POP mail address and dumps them into a file (one file one email)
Then a PHP script runs through the files and displays them.
I am having an issue with ISO-8859-1 (Latin-1) encoded email
Here's an example of the text i get: =?iso-8859-1?Q?G=EDsli_Karlsson?= and Sj=E1um hva=F0 =F3li er kl=E1r J
The way i pull emails is this code.
pop = poplib.POP3(server)
mail_list = pop.list()[1]
for m in mail_list:
mno, size = m.split()
lines = pop.retr(mno)[1]
file = StringIO.StringIO("\r\n".join(lines))
msg = rfc822.Message(file)
body = file.readlines()
f = open(str(random.randint(1,100)) + ".email", "w")
f.write(msg["From"] + "\n")
f.write(msg["Subject"] + "\n")
f.write(msg["Date"] + "\n")
for b in body:
f.write(b)
I have tried probably all combinations of encode / decode within python and php.