I am having problems changing the ‘from’ email header in the following script. Everthing else works ok but the from line in the email received is the server name and not admin@mywebsite.com:
ini_set("sendmail_from", " admin@mywebsite.com ");
$adminSendTo = "admin@mywebsite.com";
$adminSubject = "Contact Form";
$adminMessage = "Contact Form: $subfirstname $sublastname \r\rEmail: $subemail \r\rSubject of feedback: $subsubject \r\rComments: $subcommentquestion\r\n";
$adminHeaders = "From: My website Contact Form\r\n";
$adminHeaders = "Reply-To: admin@mywebsite.com";
mail($adminSendTo, $adminSubject, $adminMessage, $adminHeaders);
Do I need to change settings in the php.ini file for this to work?
Actually, you don’t provide any “From” field.
By writing:
you assign the “From…” value to
$adminHeaders, then overwrite just on the next line by a new value “Reply-To…”.Instead, you should write:
Here, “Reply-To…” will be concatenated to the actual value of
$adminHeaders, instead of overwriting it.