0

I use this code to send mail in php :

mail($to,$subject,$message,$headers);

It works perfectly but if we check the mail's full header it's gonna show the server of the site which the mail has been sent with that. I want to know is there any possible way so that we can change the full header of that and show something else in the full header in the mail.

Thanks in advance

3 Answers3

0

No. You cannot change certain headers as these are added by mail servers during mail delivery (so if is out of your reach). You can add own headers to the mail, but smtpd will still add theirs.

PS: Do not use mail(). Use something more sophisticated like PHPMailer or similar package.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • 2
    what's the problem with `mail`? –  Nov 17 '12 at 18:21
  • It is quite dumb, do not handle authentication, relies on smtpd binaries on same host etc. Using PHP Mailer is better as you can send mail via regular SMTP and do not bother building mail structure yourself (which is usually a problem for people who need to send mail but do not bother how it shall be correctly built). – Marcin Orlowski Nov 17 '12 at 18:23
0

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.

Emil Vikström
  • 90,431
  • 16
  • 141
  • 175
0

You can send whatever header you want when you send mail through any serivce/API but its up to the client (gmail, exchange, etc...) to show what kind of data to display. In addition, the SMTP server modifies or overrides header data that it deems essential.

Your header data essentially goes through at least 2 filter layers in its transit process.

Matt Lo
  • 5,442
  • 1
  • 21
  • 21