How can i use the mail by header in php?
This is what i use now:
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: test@gmail.com\r\nReply-To:test@gmail.com";
//send the email
$to = "test@gmail.com";
$subject = "This is a subject";
$body = "Hi there!";
if (mail($to, $subject, $body,$headers))
{
echo("\nMessages successfully sent!");
} else {
echo("\nMessages delivery failed...");
}
I get this on my gmail when i click on show details:
from test@gmail.com
reply-to testreply@gmail.com
to test@gmail.com
date Sat, May 14, 2011 at 12:06 AM
subject stefanos neofitidis! You commented on your poem:Tree present
mailed-by ip-1-1-1-1.ip.secureserver.net
i do not want to the ip-1-1-1-1.ip.secureserver.net to show up to the users…this is what i am trying to change!
What you want to do is add a fifth parameter in your mail() function, which needs to use the "-f" sendmail option.
For example:
Sending a message with that last parameter will change the envelope sender to "sender@domain.com". Most of the time, email providers like gmail won’t even show that address if it is set by hand(which is what you want, I’m assuming).
See https://www.php.net/function.mail for more details.