PHP mail() function sucess, but didn't receive any email
php
Solution
There are 2 reason not to send email from your localhost..
- You don't have mail server setup in your local environment
- You are not using SMTP service to send the email.
So either you have to configure the mail server but I don't think that this is a handy solution.
Better you try to use SMTP service. To do this it will be better if your use PHPMailer.
Here is an example using PHPMailer class.
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "mail.example.com"; // SMTP server example
$mail->SMTPDebug = 0; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "username"; // SMTP account username example
$mail->Password = "password";
You can use this class for any kind of email as a alternative of PHP : mail().
Problem
I'm try to sent email by my localhost php, but the problem is i didn't receive anything in my email, what should i configure? Here is my code ``` $to="someone@gmail.com"; $name="jason"; $subject="test message"; $header="From: $name"; $message="blah blah blah"; $sentmail=mail($to,$subject,$message,$header); echo $sentmail ? "email send" : "email send fail"? ``` as the result was "email send"