i have the following code
$subject = "Subject Here";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Domain Name <[email protected]>' . "\r\n";
$to = $email;
$body = '
My Message here
';
mail($to, $subject, $body, $headers);
and it send mail correctly but when i see details in the email in gmail ... it shows
from Domain Name to [email protected] date Tue, May 25, 2010 at 12:41 PM subject my subject here mailed-by mars.myhostingcompany.net
while i want to show my own address in mailed by section so that it should be mydomain.com instead of mars.myhostingcompany.net
"\r\n"; mail($to,$subject,$message,$headers);
PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters.
There are two types of sender (From), the MIME
header sender and the envelope
sender.
You send the MIME sender with in the headers in the 4th parameter of the mail()
function. You are doing this fine.
The enveloper
sender (the one you can send when sending email through sendmail or a sendmail compatible wrapper) with the -f
flag, is set in the 5th mail()
parameter, additional_parameters
, in the format you'd pass it on the command line: [email protected]
.
So your mail function would end up looking like this:
mail($to, $subject, $body, $headers, "[email protected]");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With