Python Forum
Downloading emails issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Downloading emails issue
#1
Hi Guys,

This is a strange issue i thought i would have no issues with, i'm downloading emails from my account in Python using poplib library.

Code:

def pop3_downloader(username, password, pop3server, port, use_ssl):
    """ downloads emails, also deletes after reading ... """
    # noinspection PyBroadException
    try:
        server = ''
        if use_ssl == "no":
            server = poplib.POP3(pop3server, port)
        elif use_ssl == "yes":
            server = poplib.POP3_SSL(pop3server, port)
        else:
            pass

        server.user(username)
        server.pass_(password)
        numMessages = len(server.list()[1])

        print("--> # Of Messages: " + str(numMessages))

        email_container = []
        for i in range(numMessages):
            (server_msg, body, octets) = server.retr(i + 1)
            for j in body:
                # noinspection PyBroadException
                try:
                    msg = email.message_from_string(j.decode("utf-8"))
                    email_body = msg.get_payload()
                    print(email_body)
                    email_extract_urls = re.findall(r"https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+", email_body)
                    # email_extract_urls = extract_all_urls_from_html(email_body)

                    if len(email_extract_urls) > 0:
                        email_container.append(email_extract_urls)
                except Exception:
                    pass
            # server.dele(i + 1)
        server.quit()
        return email_container

    except Exception:
        print_exception()
This is an example email:

[Image: fS4uwja.jpg]

The problem is, the long activation link at the top is not being downloaded when i view the console all i see is:

[Image: 5R534VH.jpg]

That link seems to be missing, it's the same for all test sites i have tried.

Is there something i am doing wrong? when i test in PHP i can download and see the links fine.

Thanks for any help guys.

Graham
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020