I 'am using imaplib(python) to login into gmail inbox and searching for appropriate messages.
But when I'am printing those message, links inside the message body seems to be broken.
With '3D' appended randomly.
'3D' is the hexadecimal encoding of '='. So the problem is that you aren't properly decoding the email, which can be done using python's email module and message.get_payload(decode=True).
Here's a short snippet:
import imaplib, email
imap_server = "imap.aol.com" #maybe this would be imap.gmail.com for gmail?
conn = imaplib.IMAP4_SSL(imap_server, 993)
conn.login(username, password)
conn.select()
resp, data = conn.uid('FETCH', '1:*' , '(RFC822)')
raw = data[0][1].strip()
message = email.message_from_string(raw)
decoded = message.get_payload(decode=True) #this will be the decoded body of the email message
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With