Trouble sending email using php form

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

			ini_set('SMTP', 'ssl://');
			ini_set('smtp_port', 465);
			ini_set('sendmail_from', '');
			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:" . '\\r\

			$sent = mail($to, $subject, $message, $headers) ;
			{print "Your mail was sent successfully"; }
			{print "We encountered an error sending your mail";
			echo $message;

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://” 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.

Sounds like a server problem rather than something up with your script. I’d verify that’s all in order first.

Yeah I thought so too. So I changed the server to my company’s server and tried again. And now it says “Your mail was sent successfully” only that I haven’t received any mail. What all do I need to verify? Cos I am doing this for the first time.

Keep it real simple to start with and then build the complexity back in, I cannot see where $to has been set in your code:


// ini set stuff here then:

$to = "your real email here";
$subject = "test subject";
$message = "test message";

    $sent = mail($to, $subject, $message) ;  
if( $sent ) {

echo "email sent to $to";


echo "email fail";

Insert in to your [noparse][/noparse] not becay\use email privacy is changed, so insert your own domain name…

$to = “”;
$subject = “test subject”;
$message = “test message”;

$sent = mail($to, $subject, $message) ;  

if( $sent ) {

echo “email sent to $to”;


echo “email fail”;