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
1
vote
2 answers

How to send Gmail email with multiple CC:'s

I am looking for a quick example on how to send Gmail emails with multiple CC:'s. Could anyone suggest an example snippet?
Ethan Whitt
  • 95
  • 2
  • 4
1
vote
0 answers

Problems when parsing headers from Apple Mail sent emails

I got an Python script that parses emails and extracts various things like headers, SHA's of attachments and such. This works most of the time but I have recently ran into a weird thing. If the email is sent from Apple Mail I don't seem to be able…
Swedish Mike
  • 583
  • 1
  • 8
  • 23
1
vote
2 answers

Python email header strange behavior

Python email header decoder for python2.7 or python3 seems to have some strange behavior in switching between encoded and unencoded text. from email.header import decode_header print decode_header("=?ISO-8859-1?B?QA==?=example.com"); print…
Vijay
  • 157
  • 1
  • 9
1
vote
1 answer

How to match the original message and its reply in the same thread using headers?

When a mail is sent, there are headers that are sent along and one among that is the Message-Id and this is something that we save and when sending a a mail from the application as a response to that mail, we used the Message-Id that we had and set…
logesh
  • 2,572
  • 4
  • 33
  • 60
1
vote
1 answer

Additional header problems with php function mail with a particular server

I have an email function in php: function send_mail($to, $from, $objet, $message) { $entetemail = 'MIME-Version: 1.0' . "\r\n"; $entetemail .= 'Content-type: text/plain; charset=UTF-8' . "\r\n"; $entetemail .= 'From: '.$from. "\r\n"; …
mrpx
  • 95
  • 1
  • 6
1
vote
1 answer

PHP imap_search filter X-priority header

Currently I'm writing a script to move emails from a folder to a different folder. All mails containing the X-Priority: 3 header should be moved. Part of source of the mail: Date: DATE To: NAME From: "NAME" Subject:…
Joshua Bakker
  • 2,288
  • 3
  • 30
  • 63
1
vote
0 answers

Sender field not found in emails sent using a different email address from Gmail browser based client

Let's say there is an email alice@example.com. A send-as has been set up for bob@example.com. When I send an email to someone from alice@ account using bob@ as the sender, the headers usually have a key-value pair with Sender as the key. This Sender…
Dilip
  • 1,122
  • 11
  • 31
1
vote
1 answer

Zend mail headers issue - malformed and 'content preview'

I am using zend-mail (updated very recently). I am using IMAP storage to fetch a list of messages with an inordinate (more than half) of the messages reporting a malformed header. I have reviewed the bug described at: ZendMail - error in headers but…
ebcken
  • 11
  • 2
1
vote
1 answer

Base64 email subject not decoding correctly

I'm trying to see why my base64 email subject isn't decoding. I use this Perl code to create it: use MIME::Base64; use Encode; $subject = "=?UTF-8?B?" . encode_base64(encode("utf8", $subject), "") . "?="; Which gives…
Andrew Newby
  • 4,941
  • 6
  • 40
  • 81
1
vote
3 answers

python3/email: parsing a list of email addresses with embedded commas?

I know how to use email.utils.parseaddr() to parse an email address. However, I want to parse a list of multiple email addresses, such as the address portion of this header: Cc: "abc" , "www, xxyyzz" In general, I…
HippoMan
  • 2,119
  • 2
  • 25
  • 48
1
vote
1 answer

Problem with From field in contact form and mail() function

I've got a contact form with 3 fields and a textarea... I use jQuery to validate it and then php to send emails. This contact form works fine but, when I receive an email, From field isn't correct. I'd like to want that From field shows text typed…
matteodv
  • 3,992
  • 5
  • 39
  • 73
1
vote
1 answer

Customizing email headers in WooCommerce email notifications

I am trying to write a filter that changes the reply-to address for WooCommerce email, dependent on the 'billing city' the order is made for. This works for WooCommerce emails, but doesn't seem to work for WooCommerce Advanced notifications - it…
1
vote
1 answer

How can I prevent Email Header Injection in my contact form?

I am a newbie on PHP but manage to create a working contact form. But then I got aware of Email Header Injection. How can I prevent this in best possible way? Don't want my form to be used to spam people. This is my code:
Naguah
  • 13
  • 5
1
vote
1 answer

VBA Parse Email Header Routing (Hops) Data

I'm interested in using VBA/VBscript to parse email header data. There are other answers on this site that address this to some degree, however not to the extent that I need. I have a number of message headers that I've extracted from emails and…
Craig
  • 145
  • 1
  • 12
1
vote
0 answers

PHP Mail not sending when hosted on Plesk

My first post and I really need some guidance, I have spent weeks researching and trying to understand why my mail code does not appear to be working on the corporate hosting(Plesk) vs. my personal hosting(CPanel) - (both on GoDaddy) I have a number…