We're receiving automated emails, which have a CSV attached. Using PHP, I'm grabbing mail via IMAP. I can grab the eMails and attachments no problem. However, the CSV's are attached as octet-streams.
How can I convert that to something I can actually work with? Currently when reading the contents, I'm just getting stuff that looks like this:
NzA1MTA1NTgxMzAsODgxDQo3MDUxMDU1ODEyMCw1NzkNCjcwNTEwNTU4MTEwLDQ3MQ0KNzA1MTA1==
Use base64_decode().
http://php.net/manual/en/function.base64-decode.php
Better yet, look at the encoding headers in the e-mail so that you know whether or not something is actually encoded the way you expect.
Related
I can't seem to find a way to be able to send a completely raw email with swiftmailer in php (or with any emailer to be honest).
By completely raw I mean the email itself is the actual string already encoded with header, body, attachment etc already in it.
I don't need to or want to construct the message with ->addTo() and such, I have the complete email string, just needs to be sent.
Does anyone know a way to do this?
Thanks
Can I get any help for php mime email parser/decoder like https://code.google.com/p/php-mime-mail-parser/ which does not involve any installations. I even tried Zend and decoder from phpclasses.org, but it did not help. I am unable to find how to give the input to program and take the output from as there is no tutorial for this
My aim: I need to convert mime mails from the input stream to readable text
Please help
Try this library, I have used in many application but make sure that you should have mail parser extension installed in your server.
http://codepad.org/zgUEf8lY
I am currently using Zend_Mail_Storage_Imap to read email messages using IMAP. I am able to read the email body (text and html) thanks to the documentation.
Now I'm trying to figure out how to save email attachments. I can't find anything that explains how to convert the raw content and save the attachments. How can I do this?
Try these:
http://macfoo.wordpress.com/2009/06/10/save-an-email-attachment-using-zend-mail/
http://www.electrictoolbox.com/function-extract-email-attachments-php-imap/
I found that reading emails using Zend_Mail can be a little buggy. Sometimes not all of the attachment files are recognized or in some cases imap can't even decode the body of the email .
We're using Sendgrid service to parse emails now, and it's working pretty well. They have a special api to decode emails. on the downside, it cost money, but I prefer better results.
I understand there are php IMAP functions to extract certain elements from an email stored in a mailbox. What I am trying to discover is whether this can translate to emails piped to a script.
The scripts that I have looked at for extracting the body and attachments are fairly inflexible and bulky. I sent my pipe script a variety of different email formats and it saved them in vastly different ways which makes me wary of starting to write a script myself.
Also as some of the emails sent from my work address attach a signature. Does anyone have any ideas how to combat this. I have a bunch of rather daft people who won't even understand the term 'don't add a signature when sending this email', or 'send in plain text only'.
AFAIK, the format for storing messages is not defined by any RFC however deliver, procmail and .forward all rely on the the headers being seperated from the body by a blank line.
I am looking for a solution that will enable me to connect to a mailbox, obtain an email, apply specific modifications to the email body (for example, change the content), and then forward the newly modified email to a new email address.
The trick is that such modification must not destroy the format and headers of the original email and I must not lose any attachments that were in the original email.
The sort of manipulation that will be performed will need to be done by an external process that knows the logic of my application.
The solution I am looking for can be an external software that can invoke some API for processing the content of the emails, or even API by itself that my code will invoke.
Our solution is currently based on PHP, but any other solution is also acceptable.
I started working with the Zend Mail library but I am running into problem having to understand the inner-workings of email formats. I wouldn't want to start messing around with the mime objects in the email format. I only want to alter the textual content of the message and keep the rest untouched.
http://php.net/manual/en/book.imap.php - functions that let you manipulate email systems.
What mail server are you using? In qmail its easy to process any incomming email. You can put any script in any language to process the lines of the email.
If you have IMAP access to your server you can use the php IMAP lib. http://www.php.net/manual/en/book.imap.php
I wrote a library as part of a larger open source app that may help you a bit. Its an object orientated wrapper around the PHP imap functions and can be found at google code.
Unfortunately this doesn't do exactly what you want. What in the message are you trying to change? I may be possible to just grab a raw version and specifically search out what you want to change, ignoring the whole mimetype processing altogether, and then just send the whole message along again.
Resending the email is simple enough, and this (small tutorial)* on sending email with attachments can refresh you on the basics (although most of what is in there you can skip as the attachments and mimetypes will already be built).
* I can't post the link because my reputation isn't high enough for two links in a single post, so I'll add it in a comment.