There are a few mail headers that have obvious practical reasons to be included (for example From: and Reply-To:). Then there are headers like MIME-Version: and Message-ID: which seem optional.
Assuming the number of lines of code isn't an issue, what headers should an automatically generated email ideally include? For instance, are there headers which are optional, but including them could prevent getting incorrectly flagged as spam?
Related
A lot of examples I found online about sending emails with php set the header
"X-Mailer: PHP/" . phpversion()
But I find disclosing I'm using php and its version a very bad security practice.
Is this a required header?
Let's look at what kind of header is generated.
According to RFC 2076, section 3.4, the header "X-Mailer" is, together with several others, non-standard. Which basically means that any mail software can treat it like it wants to, especially adding them or ignoring them. Absence of such headers cannot be used against the sender.
I'm pretty sure the "X-" prefix indicates "non-standard header" in SMTP message format as well, just as it does in HTTP headers or mime types.
I have to hit the minimum character limit.
NO :)
Not required, but you must verify all the headers because some providers (hotmail, yahoo, orange in France) are increasingly stringent and mark it as spam legitimate emails more easily
I'm using PHP mail and I have the following headers:
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8; format=flowed;
Content-Transfer-Encoding: 8Bit
X-Mailer: Pressflow
Errors-To: some#email.com
Return-Path: some#email.com
Sender: some#email.com
From: Some Email <some#email.com>
X-SMTPAPI: {"category":"key:some_key"}
Where some#email.com is a legitimate email, but I wouldn't disclose it here...
Is there a way to modify this header such that my mail wouldn't get sent to the spam folder in Outlook?
Look into SPF and DKIM. For an easier alternative, try email delivery services such as Mad Mimi or MailChimp.
No, otherwise spam filer would be useless
Headers aren't the only things checked by spam filters. They also check the body, otherwise, they would be pretty useless.
There are plenty of tools and articles available which will help you narrow down why your mail looks like spam.
For issues with the body text, you can use an online tool like this one
Also this has been asked so many times before, a simple search of php mail spam would have given you this question, which has not only helpful information, but a load of related questions in the comments.
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'm trying to programmatically parse my Gmail for various indexing functions, and am having trouble finding certain headers that I thought were standard email headers. I'm using the Zend IMAP library, and have no problems with authentication and otherwise viewing/manipulating my Gmail. However, I'm having trouble with some headers missing. For instance
about 1 out of 10 of the messages are missing the "message-id" header, including many sent from other gmail addresses
occasionally, though rarely, the 'content-type','content-disposition', and 'filename' headers are missing from attachment headers. These always seem to be messages that are part of a longer thread of messages.
Can anybody explain why these headers might be missing? If the "message-id" header is missing, what is used as the unique identifier? Perhaps some sort of combination of other headers?
According to RFC 5322:
The only required header fields are the origination date field and the originator address field(s). All other header fields are syntactically optional.
The same RFC says:
Though listed as optional in the table in section 3.6, every message SHOULD have a "Message-ID:" field. Furthermore, reply messages SHOULD have "In-Reply-To:" and "References:" fields as appropriate and as described below.
So Message-ID isn't strictly-speaking mandatory. If it's missing, try looking for either the In-Reply-To or References fields.
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.