Jump to content

Extracting Email Attachment (Text)


TripleDES

Recommended Posts

What's the best way to extract email attachments that's encoded in base64?  I can run the base64 encoded stuff through base64_decod(), but I want to know if there is a function to handle attachments.

 

Example:

------_=_NextPart_001_01C7C330.9D7B678C
Content-Type: text/plain;
name=report.csv
Content-Transfer-Encoding: base64
Content-Description: report_=.csv
Content-Disposition: inline;
filename=report.csv

Link to comment
Share on other sites

I do not think there is a function to handle this type of stuff.

 

You may try the base64 decode with www.php.net/readfile to display it/download it.

 

www.php.net/headers  for more examples on the readfile/download.

Link to comment
Share on other sites

Thanks.  I did find several mail parsing functions through pecl, but several of them are undocumented.

 

mailparse_determine_best_xfer_encoding — Gets the best way of encoding

mailparse_msg_create — Create a mime mail resource

mailparse_msg_extract_part_file — Extracts/decodes a message section

mailparse_msg_extract_part — Extracts/decodes a message section

mailparse_msg_extract_whole_part_file — Extracts a message section including headers without decoding the transfer encoding

mailparse_msg_free — Frees a MIME resource

mailparse_msg_get_part_data — Returns an associative array of info about the message

mailparse_msg_get_part — Returns a handle on a given section in a mimemessage

mailparse_msg_get_structure — Returns an array of mime section names in the supplied message

mailparse_msg_parse_file — Parses a file

mailparse_msg_parse — Incrementally parse data into buffer

mailparse_rfc822_parse_addresses — Parse RFC 822 compliant addresses

mailparse_stream_encode — Streams data from source file pointer, apply encoding and write to destfp

mailparse_uudecode_all — Scans the data from fp and extract each embedded uuencoded file

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.