POP3 - Mail Headers - Attachments...

alfred alfred at mazuma.net.au
Sat Nov 10 15:48:30 EST 2001


This is an example of an email I sent to myself with attachments:

From: alfred <alfred at mazuma.net.au>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20010913
X-Accept-Language: en-us
MIME-Version: 1.0
To: areynold at bigpond.net.au
Subject: test
Content-Type: multipart/mixed;
  boundary="------------040702080203030308040907"

This is a multi-part message in MIME format.
--------------040702080203030308040907
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


You could scan for Content-Type, find the boundary then scan the email 
for the boundary and then scan the next Content-Type for the type of the 
mime attachment. In this case its plain text which means its the body of 
the email. Further down you would see:

--------------040702080203030308040907
Content-Type: text/plain;
  name="run"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
  filename="run"


Which was my attachment (in this case its text again). This is the 
problem you see, the body can be an "attachment" (it all depends on how 
you look at it). I would suggest you read RFC1521, RFC1341 and RFC1522 
which talks about mime encoding and how emails handle it :)

In the end I would ditch pop though, there are more elgant ways of doing 
this :) (i.e IMAP as another poster suggested).



Donovan J. Edye wrote:

> A,
> 
> 
>>the "top" command to snaffle the mime header without grabbing the whole
>>
> And what would I be looking for as an example?
> 
> -- D
> 
> -----Original Message-----
> From: alfred [mailto:alfred at mazuma.net.au]
> Sent: Saturday, 10 November 2001 14:02
> To: Donovan J. Edye
> Cc: Linux List
> Subject: Re: POP3 - Mail Headers - Attachments...
> 
> You can't :)
> Attachments are made inline with mime headers. You could attempt to use
> the "top" command to snaffle the mime header without grabbing the whole
> message but this won't always work (e.g if there are two attachments,
> the html text and then a picture, you would probably only grab the first
> attachments details).
> 
> Donovan J. Edye wrote:
> 
> 
>>G'Day,
>>
>>I am looking for a lightweight way using POP3 to determine:
>>
>>-          If a message has an attachment
>>-          What the name of the attachment is
>>-          What size the attachment is
>>
>>I have read the RFC's and cannot readily see a way to do this. I don't
>>
> want
> 
>>to download the message to get this info. I just want to determine it from
>>the mail headers if possible. Any ideas or pointers?
>>
>>TIA
>>
>>-- Donovan
>>----------------------------------------------------------------------
>>E-Mail: d.edye at bigfoot.com <mailto:d.edye at bigfoot.com>  Web:
>>www.edye.wattle.id.au/ <http://www.edye.wattle.id.au/>
>>"If I throw a stick will you go away?"
>>"Very funny Scotty. Now beam down my pants!"
>>----------------------------------------------------------------------
>>GXExplorer - Freeware Delphi Windows Explorer Replacement
>>and Delphi Components www.gxexplorer.org
>>----------------------------------------------------------------------
>>
>>
>>
>>
> 
> 
> --
> Alfred Reynolds
> alfred at mazuma.net.au
> 
> 


-- 
Alfred Reynolds
alfred at mazuma.net.au





More information about the linux mailing list