Hi I am going crazy trying to send an email using XAMPP, my php form on my localhost server.
This is the email section of the code
if($insert_result)
{
ini_set('SMTP', 'ssl://smtp.gmail.com');
ini_set('smtp_port', 465);
ini_set('sendmail_from', 'myemail@gmail.com');
ini_set('sendmail_path', 'localhost\\C:\\Program Files\\xampp\\sendmail\\sendmail.exe');$to = $_REQUEST['email'];
$message = "Please fill out a survey form. Follow this link---> <a href='{$email_link}'>HERE</a> to load the form.<br>";
$nameTo = "Dear User";
$subject = "Form completion required!";
$headers = "MIME-Version: 1.0" . '\\r\
';
$headers .= "Content-type: text/html; charset=iso-8859-1" . '\\r\
';
$headers .= "From: myemail@gmail.com" . '\\r\
';
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail";
echo $message;
phpinfo();
}
Right now, I am trying to use gmail’s SMTP server. And it gives the following error:
Warning: mail() [function.mail]: Failed to connect to mailserver at “ssl://smtp.gmail.com” port 465, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:\xampp\htdocs\survey.php on line 328
I modified the sendmail.ini and entered my username and password in the auth_username and auth_password fields and restarted XAMPP. No result.
Earlier I tried sending using my company’s ISP server. But it says Client is not authenticated.
I printed phpinfo() to check whats wrong. Its using the same php.ini file I am modifying and the local values of SMTP and smtp_port are changing but not the master values.
Mercury is running in my XAMPP Control Panel. Do I need to setup mercury? I just can’t figure this out. I really hope someone can help me sort this out ASAP. Much appreciated.