繁体   English   中英

如何使用localhost项目中的WAMP在PHP中发送电子邮件?

[英]How to send emails in PHP using WAMP from localhost project?

我在wamp / www文件夹中有一个项目文件夹,说myproject。 我的系统上安装了最新版本的wamp。 我试图从中发送电子邮件的myproject文件夹中有abc.php文件。 当我从本地主机(localhost / myproject / abc.php)运行项目时,出现以下错误:

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()

我应该如何解决此警告? 是的,不是,我的系统上没有运行任何邮件服务器,如果现在也不想运行。 当我将该站点托管到任何服务器时,我将使用他们的邮件服务器来配置我的smtp。 但是目前在localhost上,我应该如何使自己能够发送电子邮件。 我正在尝试使用ini_set方法来完成这项工作。

            $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类是使用PHP发送邮件的最佳选择。 链接在这里

http://code.google.com/a/apache-extras.org/p/phpmailer/source/browse/trunk/class.smtp.php?r=170

我本人是PHPMailer的忠实粉丝。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM