Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7978443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:29:36+00:00 2026-06-04T09:29:36+00:00

i have printer status reports sent on my email. i would like to download

  • 0

i have printer status reports sent on my email. i would like to download them and process one by one, and all information to put in some database for further processing.
i would like to use python3 as i start to learn it.
i have this code:

import getpass
import poplib

server = poplib.POP3('pop3.mailserver.com' )

server.user('report@mailserver.com')
server.pass_('pswd')

numMessages = 1 #len(server.list()[1])
emails, total_bytes = server.stat()

print("{0} emails in the inbox, {1} bytes total".format(emails, total_bytes))

for i in range(numMessages):  
    for msg in server.retr(i+1)[1]:
        print(msg)

and what i get is whole email message (with headers and body) in this format:

b'Return-Path: <"tever">'
b'Delivered-To: reportc@mailserver.com'
b'Received: (qmail 13193 invoked by uid 89); 23 May 2012 08:44:51 -0000'
b'Received: by simscan 1.2.0 ppid: 13156, pid: 13164, t: 0.1620s'
b'         scanners: clamav: 0.97-exp/m:53 spam: 3.3.1'
b'X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mxavas16.ad.aruba.it'
b'X-Spam-Level: *'
b'X-Spam-Status: No, score=1.4 required=5.0 tests=FH_FROMEML_NOTLD,INVALID_MSGID,'
b'\tT_FILL_THIS_FORM_SHORT autolearn=disabled version=3.3.1'
b'Received: from unknown (HELO smtplq02.aruba.it) (62.149.158.35)'
b'  by mxavas16.ad.aruba.it with SMTP; 23 May 2012 08:44:51 -0000'
b'Received: (qmail 30750 invoked by uid 89); 23 May 2012 08:44:51 -0000'
b'Received: from unknown (HELO smtp8.aruba.it) (62.149.158.228)'
b'  by smtplq02.aruba.it with SMTP; 23 May 2012 08:44:51 -0000'
b'Received: (qmail 30979 invoked by uid 89); 23 May 2012 08:44:51 -0000'
b'Received: from unknown (HELO NM7ACD31) (email@server.it@83.xxx.xxx.xxx)'
b'  by smtp8.ad.aruba.it with SMTP; 23 May 2012 08:44:51 -0000'
b'Date: Wed, 23 May 2012 10:46:34 +0200'
b'From: tever'
b'Subject: QEQ1313212'
b'To: report@mailserver.com'
b'Message-Id: <201205231046340001d806.TEVER>'
b'Mime-Version: 1.0'
b'Content-Type: text/plain; charset="utf-8"'
b'Content-Transfer-Encoding: base64'
b''
b'RXF1aXBtZW50IElEOiAgICAgICAgICAgICANCk1vZGVsIE5hbWU6ICAgICAgICAg'
b'ICAgICAgQ0RDIDE3MjVfRENDIDI3MjUNClNlcmlhbCBOdW1iZXI6ICAgICAgICAg'
b'ICAgUUVRMTMxMzIxMg0KTWV0ZXJEYXRlOiAgICAgICAgICAgICAgICBXZWQgMjMg'
b'TWF5IDIwMTIgMTA6NDY6MzQNCkNvdW50ZXJzIGJ5IEZ1bmN0aW9uDQogUHJpbnRl'
b'ZCBQYWdlcw0KICBDb3BpZXI6ICAgICAgICAgICAgICAgICAyMjE1ICAgIA0KICBQ'
b'cmludGVyOiAgICAgICAgICAgICAgICAxMTEyMDQgIA0KICBGQVg6ICAgICAgICAg'
b'ICAgICAgICAgICA5MzIgICAgIA0KICBUb3RhbDogICAgICAgICAgICAgICAgICAx'
b'MTQzNTEgIA0KIFNjYW5uZWQgUGFnZXMNCiAgQ29waWVyOiAgICAgICAgICAgICAg'
b'ICAgMTkxOSAgICANCiAgRkFYOiAgICAgICAgICAgICAgICAgICAgMjIwNyAgICAN'
b'CiAgT3RoZXI6ICAgICAgICAgICAgICAgICAgMTgyMiAgICANCiAgVG90YWw6ICAg'
b'ICAgICAgICAgICAgICAgNTk0OCAgICANCkNvdW50ZXJzIGJ5IFBhcGVyIFNpemUN'
b'Ck1vbm9jaHJvbWUNCiAgQTM6ICAgICAgICAgICAgICAgICAgICAgNDU0ICAgICAN'
b'CiAgQjQ6ICAgICAgICAgICAgICAgICAgICAgMCAgICAgICANCiAgQTQ6ICAgICAg'
b'ICAgICAgICAgICAgICAgMTA4MDQ4ICANCiAgQjU6ICAgICAgICAgICAgICAgICAg'
b'ICAgNDI3ICAgICANCiAgQTU6ICAgICAgICAgICAgICAgICAgICAgMCAgICAgICAN'
b'CiAgRm9saW86ICAgICAgICAgICAgICAgICAgMSAgICAgICANCiAgTGVkZ2VyOiAg'
b'ICAgICAgICAgICAgICAgMCAgICAgICANCiAgTGVnYWw6ICAgICAgICAgICAgICAg'
b'ICAgMCAgICAgICANCiAgTGV0dGVyOiAgICAgICAgICAgICAgICAgMCAgICAgICAN'
b'CiAgU3RhdGVtZW50OiAgICAgICAgICAgICAgMCAgICAgICANCiAgT3RoZXIxOiAg'
b'ICAgICAgICAgICAgICAgMCAgICAgICANCiAgT3RoZXIyOiAgICAgICAgICAgICAg'
b'ICAgMiAgICAgICANCk1vbm8gQ29sb3INCiAgQTM6ICAgICAgICAgICAgICAgICAg'
b'ICAgMCAgICAgICANCiAgQjQ6ICAgICAgICAgICAgICAgICAgICAgMCAgICAgICAN'
b'CiAgQTQ6ICAgICAgICAgICAgICAgICAgICAgMCAgICAgICANCiAgQjU6ICAgICAg'
b'IE90aGVyIEVycm9ycw0KDQo8V2VkIDIzIE1heSAyMDEyIDEwOjQxOjU0Pg0KICBb'
b'IF0gQWxsIE90aGVyIEVycm9ycw0KDQo8V2VkIDIzIE1heSAyMDEyIDEwOjQ1OjIx'
b'Pg0KICBbKl0gQWRkIFBhcGVyDQoNCi0tLS0tLS0tLS0tLS0tLS0tLS0NCkNEQyAx'
b'NzI1X0RDQyAyNzI1DQpbMDA6YzA6ZWU6N2E6Y2Q6MzFdDQotLS0tLS0tLS0tLS0t'
b'LS0tLS0t'
b'DQo='
b''

what i need is to process body content line by line and if it matches i need to delete it from the server.

and tips how to do it?

many thanks
gerard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:29:37+00:00Added an answer on June 4, 2026 at 9:29 am

    maybe if you start by parsing the message it would be a good start:

    # ... get your message ...
    # msg = [b'Return-Path: <"tever">'
    #        b'Delivered-To: reportc@mailserver.com', ... ]
    
    import email
    
    # decode simple non-multipart message
    message = email.message_from_bytes(b'\n'.join(msg))
    payload = message.get_payload(decode=True)
    payload = payload.decode(message.get_content_charset())
    print(payload)
    

    then you can do with the payload whatever you need…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have printer stylesheet setup on my site. It works in all browsers but
I have a OKI printer which displays the job status while the file is
My Goal I would like to have a main processing thread (non GUI), and
I would like to parse the xml data from a remote website http://services.faa.gov/airport/status/IAD?format=xml ...But
I have a pretty long and wide datagrid which I would like to send
I would like to improve the performance of a Python script and have been
I have a printer that doesn't have the driver for my windows server 2008,
I have implemented a printer delivery extension based on MS example in SSRS 2005.
I am using a dot matrix printer and have to do a continious printing
I have the next code: class Printer{ Activity activity; public Printer (Activity activity) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.