Reputation:
In my mail client or gmail the sender is always apache@hosting12
Any way to fix this issue? I have tried setting the headers like these with no success. Can sombody please help me?
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <'$from'> \r\n";
$headers .= "Reply-To: <'$from'> \r\n";
$headers .= "Return-Path: <'$from'>\r\n";
$headers .= "X-Mailer: PHP \r\n";
or
$headers = "From: $from";
Upvotes: 3
Views: 15929
Reputation: 4094
I found that answer on a french forum. http://www.developpez.net/forums/d413965/php/outils/configuration-sendmail_path-sender/
You can add a 5th param to the mail function:
mail($mail_recipient, $subject, $message, $headers, '-f'.$mail_from);
Ths '-f' + mail_from force the system to send the email as the mail_from.
Upvotes: 8
Reputation: 81711
Please remove single quotation mark from around $from
and use {$from}
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
or you can use following signatures to pass from
mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
EDIT:
You also want to check sendmail_from
setting in php.ini
file.
Upvotes: 1
Reputation: 90746
There are extra single quotes in your header. Try like this:
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <$from> \r\n";
$headers .= "Reply-To: <$from> \r\n";
$headers .= "Return-Path: <$from>\r\n";
$headers .= "X-Mailer: PHP \r\n";
Also you can remove the unnecessary "Reply-To" and "Return-Path".
Upvotes: 4