I'm having difficulties with xampp and the mail function as the title says, according to the log file its sending however its not. I send myself test massges and never receive anything.
here is the relevant code from my php.ini
as well as the php code for sending the email
I know the mail function is returning true as on the page it displays sent. I also checked my gmail account and all the emails are supposed to work so i dunno what the problem is.
here is the relevant code from my php.ini
Code:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP =smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = [email protected]
; 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(), even in safe mode.
;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
; Log all mail() calls including the full path of the script, line #, to address and headers
mail.log = "\xampp\php\logs\php_mail.log"
as well as the php code for sending the email
Code:
<?php
//we need to get our variables first
$email_to = '[email protected]'; //the address to which the email will be sent
$name = $_POST['contact_name'];
$email = $_POST['contact_email'];
$subject = $_POST['contact_subject'];
$message = $_POST['contact_message'];
/*the $header variable is for the additional headers in the mail function,
we are asigning 2 values, first one is FROM and the second one is REPLY-TO.
That way when we want to reply the email gmail(or yahoo or hotmail...) will know
who are we replying to. */
$headers = "From: ". $email . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
if(mail($email_to, $subject, $message, $headers)){
echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
}else{
echo 'failed';// ... or this one to tell it that it wasn't sent
}
?>
I know the mail function is returning true as on the page it displays sent. I also checked my gmail account and all the emails are supposed to work so i dunno what the problem is.