maaz azad
maaz azad

Reputation: 1

how to remove 'via' or 'mailed by' in email using php mail function

Following is how I am using the php mail function to send emails to registered users in my website:

mail($email, $subject, $message,'From: MySite <[email protected]>', "-f [email protected]");

The problem is that the recipients are getting 'From [email protected] via eigbox.net'

How can I remove that eigbox.net? I searched on google and many are saying that you cannot remove it and some are saying that I should have that '-f [email protected]', which as you can see I have but still it doesn't work. I even contacted my webhost but they were not very helpful.

Please let me know if there is anyway I can remove that and thank you very much.

Upvotes: 0

Views: 7241

Answers (1)

anon
anon

Reputation:

Try the following:

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$to = '[email protected]';
$from = '[email protected]';
$subject = 'e-mail subject';
$body = 'e-mail body';

mail($to, $subject, $body, $headers, "-f$from");

Unrelated note: I suggest using PHPMailer or Swiftmailer as an alternative to mail() function. It gives you more control and is robust.

Upvotes: 3

Related Questions