Reputation: 47
I'm trying to test if the return-path will bounce back on my gmail, but not.
I'm testing to send it to my email ([email protected]): it works!
And send to unknown email ([email protected]): it didn't bounce back.
Here's my code
<?php
$message = '
<html>
<head>
<title>Sample Email</title>
</head>
<body>
Sample Email
<br /><br />
<a href="http://asd.com/[email protected]">Click here to Unsubscribe</a>
</body>
</html>
';
$sender = "[email protected]";
$email_address = "[email protected]";
$subject = "Testing Email";
$template_name = "Sample Email";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Return-Path: [email protected]' . "\r\n";
$headers .= 'From: '.$sender.'' . "\r\n";
if(mail($email_address, $subject, $message, $headers, '[email protected]'))
echo "{$i}. {$email_address} - <span style='color:green'>Successfully</span> Sent [{$template_name}]<br />";
else
echo "{$i}. {$email_address} - <span style='color:green'>Unsuccessfully</span> Sent [{$template_name}]<br />";
Upvotes: 0
Views: 673
Reputation: 3087
You have two solutions to this issue: First one is leave blank in the php.ini configuration file the "sendmail_from" variable. This way you could add the additional parameters in the mail function like you have in your code.
The second approach, is set "sendmail_from" in php.ini if you want to have always the same "Return-Path" for every email.
Upvotes: 1