Complete Mail Header

change full header for sending mail in php

All mail servers will add an Received header row to the message. You can configure your own server(s) to not add such a header, and even to remove other such headers, but you cannot control the behavior of other mail servers. This means that the first server outside your environment will add the IP and hostname of your last server, and there is nothing you can do about it.

How to read email headers?

Might i recommend wikipedia's extensive article on the subject? The RFC's in the article should answer any questions you may have.

http://en.wikipedia.org/wiki/Email#Message_format

Simple php mail header with variable

You are missing a dot (period) after your first 'Bcc: '.

it should be

  $headers .= 'Bcc: ' . $from . "\r\n";

UPDATE:

You need to use double quotes when using special characters like \r and \n. In your original example code you used double quotes, but I see now with your full code that you're not actually using them, you're using single quotes.

Single quoted strings in PHP show special characters as literals.

So your lines should be

$headers .= 'From: ' . $from . "\r\n";
$headers .= 'Bcc: ' . $from . "\r\n";

php mail() headers prevent email from sending

"MIME-Version: 1.0 \r\n" . PHP_EOL . is too many newlines. Don’t use PHP_EOL at all; use \r\n, and only once.

You also have an extra single quote after charset.

$headers =
"From: website <donotreply@website.com>\r\n" .
"BCC: customer1@hotmail.com\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=UTF-8";

Why do RECEIVED email headers seem to be out of order chronologically?

The answer to this question is documented in rfc5321, section 4.4 as follows:

When an SMTP server receives a message for delivery or further

processing, it MUST insert trace ("time stamp" or "Received")

information at the beginning of the message content
, as discussed in

Section 4.1.1.4.

This line MUST be structured as follows:

o The FROM clause, which MUST be supplied in an SMTP environment,
SHOULD contain both (1) the name of the source host as presented
in the EHLO command and (2) an address literal containing the IP
address of the source, determined from the TCP connection.

o The ID clause MAY contain an "@" as suggested in RFC 822, but
this
is not required.

o If the FOR clause appears, it MUST contain exactly one
entry, even when multiple RCPT commands have been given. Multiple
s raise some security issues and have been deprecated, see
Section 7.2.

An Internet mail program MUST NOT change or delete a Received: line
that was previously added to the message header section. SMTP

servers MUST prepend Received lines to messages; they MUST NOT change
the order of existing lines or insert Received lines in any other

location.

Correct email headers for delivering mailing list mail

From: and To: headers are for 'display purposes' (this is what is presented in the users email application as sender and recipient). They don't have to match to the real sender/recipient of a email message which are called "envelope sender"/"envelope recipient" and are specified in the smtp protocol ("MAIL FROM:...." "RCPT TO...").

Example:

Mail comes from alice@example.com, goes to list@example.org and is being delivered to bob@example.net:

From Alice to The list Server:

Envelope Sender: alice@example.com

Envelope Recipient: list@example.org

From Header: alice@example.com

To Header: list@example.org

From the list Server to bob:

Envelope Sender: list-bounces@example.org (so error messages go to the list server, not to alice!)

Envelope Recipient: bob@example.net

From Header: alice@example.com (Bob sees Alice as the sender, this is not modified by the list server)

To Header: list@example.org (again, not modified by the list server)

Optional: Reply-To header: list@example.org (So, if bob presses reply, the reply goes to the list - added by the list server ) - beware: some people do not like reply-to header munging

Additional headers:

Some email clients also understand these additional headers and present special mailinglist features to the user:

  • list-Id
  • list-Post
  • list-help
  • list-unsubscribe
  • list-owner

https://www.ietf.org/rfc/rfc2919.txt
https://www.ietf.org/rfc/rfc2369.txt

Also, you could add a header

Precedence: bulk

which for example tells intelligent out-of-office implementations not to send out-of-office replies to the list. But this is discouraged by RFC 2076.

Save complete email, body and header, as PDF

Try to save in the MHTML format (it preserves the embedded pictures and includes the headers) using MailItem.SaveAs, then open the MHTML file using Word object model and save it as a PDF file.



Related Topics



Leave a reply



Submit