1 Replies - 237 Views - Last Post: 24 February 2014 - 12:45 AM Rate Topic: -----

#1 M2com  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-February 14

get_payload() Output is blank

Posted 22 February 2014 - 10:39 PM

Everytime I use get_payload() the output is blank. Here's a sample of the raw email I'm trying to parse:

['Return-Path: cellphone#here@mms.att.net', 'To: blank@mysite.com', 'Date: Sun, 23 Feb 2014 04:51:11 -0000', 'Subject: (no subject)', 'Message-ID: <1039425765.16450041393131071735.JavaMail.nems$...

I don't get any errors, I just get a blank output.

Thanks and let me know what I can do to help you help me! Thanks!

PS: The email is coming from mss.att.net that gets a text from my phone.

Is This A Good Question/Topic? 0
  • +

Replies To: get_payload() Output is blank

#2 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: get_payload() Output is blank

Posted 24 February 2014 - 12:45 AM

You have to show us exactly the message that you are trying to handle because I created this test here:

import email

data = """
MIME-Version: 1.0
Received: by 10.229.34.6 with HTTP; Sun, 23 Feb 2014 23:40:57 -0800 (PST)
Date: Mon, 24 Feb 2014 00:40:57 -0700
Delivered-To: mentalfloss@gmail.com
Message-ID: <CAFRhAAV1gNNaiZjJZ4tZmLAiut46AAzatrCxfWuBzpoRhC8SBw@mail.gmail.com>
Subject: Test
From: mentalfloss <mentalfloss@gmail.com>
To: mentalfloss <mentalfloss@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Test"""
msg  = email.message_from_string( data )
payload = msg.get_payload(decode=True)
print payload



And it works fine:

output said:

brandon@mothership:~/pythons/trivialproject$ python emalthing.py
MIME-Version: 1.0
Received: by 10.229.34.6 with HTTP; Sun, 23 Feb 2014 23:40:57 -0800 (PST)
Date: Mon, 24 Feb 2014 00:40:57 -0700
Delivered-To: mentalfloss@gmail.com
Message-ID: <CAFRhAAV1gNNaiZjJZ4tZmLAiut46AAzatrCxfWuBzpoRhC8SBw@mail.gmail.com>
Subject: Test
From: mentalfloss <mentalfloss@gmail.com>
To: mentalfloss <mentalfloss@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Test


So, I'm certain that it's the message itself that isn't parsing right because I too got a blank return when I tried your malformed one.

This post has been edited by MentalFloss: 24 February 2014 - 12:46 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1