Is it possible to send a MIME message as it is, without adding any headers? For example, if I have a correct MIME message with all headers and content saved to a text file, is it possible to use the contents of this file without modification and send it via SMTP?
Apparently both python's SMTP.sendmail and PHP smtp::mail require at least "To:" and "From:", and passing the complete message to these functions doesn't seem to work.
It appears from the documentation that python's SMTP.sendmail should take a sender, a set of recipients, and a verbatim MIME message like the one you have. (The split here between the sender/recipients and the message itself is because you're talking SMTP. The SMTP envelope determines the actual recipients and is actually independent of the message payload.) So you should be good to go with SMTP.sendmail.
You could read up to the first blank line, use those as additional headers, then send the rest in the body.
Related
This PHP Mime Mail Parser library is very useful:
https://github.com/php-mime-mail-parser/php-mime-mail-parser
Example request:
$arrayHeaderTo = $parser->getAddresses('to');
It lets you analyze the intended recipient, sender, subject, etc., of an email message in RFC822 standards format.
For those like me that are even more curious about an email message, such as which mailserver originated the message, I'd like to extend the library to have a dependable way to print this value, regardless of how it's found in the headers.
https://toolbox.googleapps.com/apps/messageheader/analyzeheader
Google provides a tool for analyzing message headers. I pasted an example here:
In this example, it would extract that complete server address ( ec2-54-245-11-255.us-west-2.compute.amazonaws.com ), and if possible, that server's IP, too. Assuming a good deal of these two values (mailserver, mailserverIP) are going to be spoofed, I would still like to see the values that are included in the header, dependably, regardless of how that header is structured, or wherein they appear.
So I guess this is a question for those who are very familiar with email headers, and a solid way to read them to extract this information.
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
The company I work for provides bulk-mailing functionality to our clients [double opt-in, not spam, I promise] and we get a figurative ton of reports back via Feedback Loops from AOL, Comcast, Yahoo, etc. These are generally from people that signed up, don't want it anymore, have been conditioned to not click 'Unsubscribe' links, [because "that's how the spammers get you"] and simply mark all the messages as spam.
Now, these FBL emails follow a specific format where the message is multipart, there are one or two text parts, and then the original message is attached, usually with all recipient information stripped out. This attached email is also multipart and contains the unsubscribe link, but the section in the attached email the link occurs in is quoted-printable encoded and the link is longer than what quoted-printable allows for in a line, so it get munged. Occasionally the section seems to get base64-encoded, I think it happens if the client is using a fancy language like chinese/japanese/etc.
What I need is a mime/multipart data parser that can give me these parts. PHP has oh so helpfully not implemented any form of multipart parser that I can find outside of what's internal to either their horrid IMAP functions, or internal to PHP itself which processes multipart form data.
Does anyone know of something I can use for this short of having to write my own? I had found one script, but it relies on old PECL functionality that relies on a custom-compilation of PHP which is not an option for this server.
TL;DR: PHP's imap_* functions will parse the parts of the message received from the server, but I need to parse the parts of an email attached to the email downloaded from the server.
This guy's script is ugly as sin, but it gets the job done:
http://www.phpclasses.org/package/3169-PHP-Decode-MIME-e-mail-messages.html
The exchange server I am working with is about 10 years old and I have no control over any of its settings. It strips the MIME header on every email's body and I need that MIME header so I was thinking if its possible to put echo statements or some html statements kind of like SQL injections in the input that would add the MIME header before the body. Is this possible?
Nothing can cause the behaviour that you are asking. The MIME header has to be set prior to sending the email.
Even if you have some kind of javascript that injects the MIME into the email header, it would do so after the email is loaded by the client. This would not cause the client to understand the MIME header.
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.