I really need a quick fix and haven't found any solution to my problem. I want to send email to the user but the sender name always shows Apache.
Here is my coding.
<?php
$password = rand(1000,9999);
$firstname = "syamsul";
$surname = "rizal";
$email = "[email protected]";
$max_id = 3;
//Generate Email
$to = $email;
$subject = "Welcome to ShopOnline!";
$message = "Dear " .$firstname. ", welcome to use ShopOnline! Your Customer id is " .$max_id. " and the password is ".$password.".";
$headers = "From [email protected]" ;
// send mail
mail($to,$subject,$message,$headers, "-r [email protected]");
echo "Thank you for sending us feedback";
?>
And why i can't send this email to gmail account but works to non-gmail account? Thanks in advance!
set your header like
$headers = "From: [email protected]" . "\r\n" .
"Reply-To: [email protected]" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
UPDATE 2 :
with sender name
$headers = "From: Sender_Name<[email protected]>" . "\r\n" .
"Reply-To: [email protected]" . "\r\n" .
"X-Mailer: PHP/" . phpversion();