I am new to python and trying to receive and resend an email using poplib and smtplib:
messages = [pop_conn.retr(i)[1] for i in range(1, mail_count + 1)]
#decode messages
messages = [[line.decode("utf-8") for line in message] for message in messages]
# Concat messages
messages = ["\n".join(msg) for msg in messages]
#...
for message in messages:
smtp_conn.sendmail(args.address, args.target, message)
In the debugger all message strings look good, but in the sendmail call following error occurs:
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 17938: ordinal not in range(128)
What am i doing wrong?