I would like to send a simple test mail using SMTP gmail with my gmail adress to the same gmail adress. I use Mercury (included in Xampp) mail to send the mail. The problem is I don't receive the mail. My gmail account doesn't have the double factor authentication.
This is the php.ini
:
[mail function]
; For Win32 only.
; http://php.net/smtp
; SMTP = smtp.gmail.com
; smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = mymail@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail().
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=Off
This is the sendmail.ini
:
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=mymail@gmail.com
auth_password=mypassword
force_sender=mymail@gmail.com
This is my PHP code :
$name = "Me";
$email = "mymail@gmail.com";
$message = "Hellooo";
// Create the email and send the message
$to = "mymail@gmail.com"; // Add your email address inbetween the "" replacing yourname@yourdomain.com - This is where the form will send a message to.
$subject = "Nouveau message";
$body = "Un nouveau message a été envoyé depuis le formue";
$header = "From: mymail@gmail.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$retour = mail($to, $subject, $body, $header);
echo $retour;
The result is 1
.
This is the logs : Logs