Questions tagged [email-headers]

E-mail headers are the headers at the beginning of an e-mail that define various properties (e.g. `From` or `Reply-To`) of the e-mail.

In an e-mail, the body (content text) is always preceded by header lines that identify particular routing information of the message, including the sender, recipient, date and subject. Some headers are mandatory, such as the FROM, TO and DATE headers. Others are optional, but very commonly used, such as SUBJECT and CC. Other headers include the sending time stamps and the receiving time stamps of all mail transfer agents that have received and sent the message. In other words, any time a message is transferred from one user to another (i.e. when it is sent or forwarded), the message is date/time stamped by a mail transfer agent (MTA) - a computer program or software agent that facilitates the transfer of email message from one computer to another. This date/time stamp, like FROM, TO, and SUBJECT, becomes one of the many headers that precede the body of an email.

Characteristics

A single email header has some important characteristics, including perhaps the most important part of an email - this is the KEY:VALUE pairs contained in the header. Looking at the above, you can tell some of the KEY:VALUE pairs used. Here is a breakdown of the most commonly used and viewed headers, and their values:

  • From: sender's name and email address (IP address here also, but hidden)
  • To: recipient's name and email address
  • Date: sent date/time of the email
  • Subject: whatever text the sender entered in the Subject heading before sending

Routing

Email headers also provide information on the route an email takes as it is transferred from one computer to another. As mentioned earlier, mail transfer agents (MTA) facilitate email transfers. When an email is sent from one computer to another it travels through a MTA. Each time an email is sent or forwarded by the MTA, it is stamped with a date, time and recipient. This is why some emails, if they have had several destinations, may have several RECEIVED headers: there have been multiple recipients since the origination of the email. In a way it is much like the same way the post office would route a letter: every time the letter passes through a post office on its route, or if it is forwarded on, it will receive a stamp. In this case the stamp is an email header.

List of Email Header Fields

IANI maintains a list of email headers here.

405 questions
4
votes
2 answers

REGEX - ignore new line characters

I came across this line of code: preg_match_all("!boundary=(.*)$!mi", $content, $matches); but for Content-Type: multipart/alternative; boundary=f403045e21e067188c05413187fd\r\n It returns f403045e21e067188c05413187fd\r When it should…
Matheus Simon
  • 668
  • 11
  • 34
4
votes
1 answer

Best way to store Email-body in database

I'm working on some sort of application where I can get emails from my inbox via a cron job, where i just insert mail-from, mail-subject and mail-body into a MySQL database. The problem i'm having is with the different mailtypes like HTML mails,…
Bert Maurau
  • 979
  • 5
  • 21
4
votes
5 answers

PHP Mail - Multiple or malformed newlines found

we upgraded our version of PHP and are now getting the error " Warning: mail(): Multiple or malformed newlines found in additional_header". I've created experimenting with different things but haven't gotten anything to work. I apologize as I'm not…
user1344849
  • 41
  • 1
  • 1
  • 2
4
votes
3 answers

AOL Rejecting email sent via PHP mail (error 5.2.1)

Recently AOL has started rejecting emails sent from my production server. Customers make product enquiries through my site and can "cc" themselves if they wish. I check for spam (e.g. don't send if request contains banned phrases, urls, etc).…
SteveJarvis
  • 63
  • 1
  • 1
  • 3
4
votes
1 answer

sendgrid multipart/alternative image from base64

I can't get Sendgrid (using node.js) to send an email with a embedded base64 image in the html. I think I'm quite close... var base64img='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQgAAAFXCAYAAABeLtDdAAAgAElEQVR4Xu19CXhURdb2ISsJgSQ';//shortened…
Ben Muircroft
  • 2,936
  • 8
  • 39
  • 66
4
votes
1 answer

How can I add an X-header field to Gmail header using javascript?

I'm writing a Chrome extension that builds on Gmail and which needs to add several proprietary header fields to the mail header before the message is sent. My app logic goes as follows: after the user composes a message in Gmail and presses Send…
4
votes
1 answer

Java add header in MimeMessage msg

Problem that i'm solving is that when i send mail if the recipient (to mails, cc/bcc) not exist, i don't want sender to get Delivery Status Notification (Failure) mail. The solution that i'm implementing is adding new header in mail…
Mr.Java
  • 369
  • 4
  • 16
4
votes
1 answer

Determining if a MIME email part is a file or message text

As part of some email batch processing, we need to decode and clean up the messages. One critical part of that process is separating the mail bodies of a message and the mail attachments. The trickiest part is to determine when a…
C2H5OH
  • 5,452
  • 2
  • 27
  • 39
4
votes
1 answer

JavaMail is losing some POP3 message headers and treats multipart/mixed as text/plain

I am having a strange issue parsing some POP3 messages in JavaMail 1.4.4 - Java 1.4, also in Java 1.6. I am parsing a com.sun.mail.pop3.POP3Message retrieved from a Windows 2003 POP3 service mailbox. When I go through the getAllHeaderLines()…
3
votes
3 answers

Sending Email with PHP and ensuring it doesn't get blocked

I want to send an HTML email with PHP. I was wondering what headers should be used in the email to ensure it doesn't get blocked or end up in SPAM folders. The email contents will contain CSS and HTML. The reply-to field will be different than the…
user2385136
3
votes
1 answer

How to identify emails sent by humans?

I am working on a project, where I need to identify emails sent by real humans as opposed to bulk mails, notifications and newsletters. Is there any definite way of doing that? Is there any information in email header which can help. I am working on…
Kuldeep Kapade
  • 1,095
  • 3
  • 12
  • 17
3
votes
1 answer

How do I get Chinese characters into the subject line of an email message?

I'm trying to send an email with Chinese/Taiwan characters in the subject line. The user entered email content shows up correctly in Chinese, but I'm having problems with the subject line. I'm using Rails 3.0.9 and have it configured to send…
3
votes
0 answers

How to forward an email with the original headers?

I am writing a program that polls an incoming mailbox (to which anyone who knows about it can post), reformats the info, then forwards the mail on to the correct address according to a predefined convention. For example, the incoming mail has: From…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
3
votes
1 answer

Email header with multiple received fields: How can this happen and can this be used to fight SPAM

I often receive fishing /SPAM emails with multiple received fields. First, I'd like to understand how one email header can have more than one received field. Second, I'd like to know if I can use this to fight SPAM. Here is an example: …
3
votes
2 answers

SMTP: Change Message-ID domain in sending emails from Laravel 5.7 (Swift Mailer)

Laravel 5.7 sends emails using Swift Mailer. By default, all sent emails will have the Message-ID header with the domain swift.generated (eg. Message-ID: <90b9835f38bb441bea134d3ac815dd6f@swift.generated>). I would like to change the domain…
checker284
  • 1,286
  • 3
  • 14
  • 29