I have a project folder say myproject in wamp/www folder. I have latest version of wamp installed on my system. I have abc.php file in myproject folder from which I am trying to send email. When I am running my project from localhost (localhost/myproject/abc.php), I am getting following error:
Warning: mail(): Failed to connect to mailserver at "mail.google.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
How should I resolve this warning? Right not I don't have any mail server running on my system and I also don't want to run if for now. When I will host this site to any server, then I will use their mail server to configure my smtp. But for now on localhost, how should I make myself able to send emails. I am trying to use ini_set method to do the job.
$to=$_POST["email"];
$subject="Hi Message";
$msg="mail contents";
$headers="From: no-reply@mydomainname.com";
//ini_set("SMTP","mail.google.com");
//ini_set("smtp_port","25");
if(mail($to, $subject, $msg, $headers))
{
$msg="Email sent successfully.";
echo $msg;
}
else
{
$msg="Email sending error";
echo $msg;
}
SMTP class is the best option to send mail in PHP. Here is the link
http://code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.smtp.php?r=170
我本人是PHPMailer的忠实粉丝。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.