Jump to content

Problem Setting up PHP to use mail ( )


OilSheikh

Recommended Posts

Hi,

 

I am trying to run this code and I keep on getting the error message :

 

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\ZSOFT\XAMPP\xampp\htdocs\register.php on line 96

 

Any ideas, guys?

 

#########	SEND A REGISTRATION CONFIRMATION E-MAIL	##########

if ($adduser)
{
$recipient = "'".$_POST['email']."'";
$subject = "Registartion Confirmation";
$mailheaders = "From: Express PC Sales <[email protected]> \n";
$msg = "Thank you for registering at Express PC Sales. Your Account is now active. <br><br> If you DID NOT register on our site, please reply back and your account will be removed from our system.";
mail($recipient, $subject, $msg, $mailheaders);
}


?>

 

Btw, I m doing this from localhost AND the FROM e-mail must be xxx@hotmail.com.

 

Any help would greatly be appreciated. Tnx.

Link to comment
https://forums.phpfreaks.com/topic/47056-problem-setting-up-php-to-use-mail/
Share on other sites

I changed my PHP.INI file.

 

[mail function]
; For Win32 only.
SMTP = mail.hotmail.com
smtp_port = 25

; For Win32 only.
sendmail_from = [email protected]

 

And this is the updated PHP code I am using

 

#########	SEND A REGISTRATION CONFIRMATION E-MAIL	##########

if ($adduser)
{
$emailaddress = "'".$_POST['email']."'";
$to = $emailaddress;
$subject = "Registartion Confirmation";
$header = "from: Express PC Sales <[email protected]>";
$message = "Thank you for registering at Express PC Sales. Your Account is now active. \n\n If you DID NOT register on our site, please reply back and your account will be removed from our system.";
$sentmail = mail($to,$subject,$message,$header);    ### Line 100
}


 

Upon running it, I get this error:

 


[b]Warning: mail() [function.mail]: Failed to connect to mailserver at "mail.hotmail.com" port 251, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\ZSOFT\XAMPP\xampp\htdocs\register.php on line 100
[/b]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.