【问题标题】:php localhost mail not getting sent using xamppphp localhost邮件未使用xampp发送
【发布时间】:2015-01-05 06:42:20
【问题描述】:

我已经按照其他人的指示配置了我的 php.ini 和 sendmail 设置,但是我仍然无法使用 PHP 中的 mail() 函数从本地主机发送任何邮件。

这些是我的 php.ini [邮件功能] 设置

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = localhost
; smtp_port = 25



sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"


;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"


and this is my sendmail.ini settings

smtp_server=smtp.gmail.com


; smtp port (normally 25)

smtp_port=587



smtp_ssl=tls


error_logfile=error.log

auth_username= joel.paul69@gmail.com
auth_password= examplepassword

我的操作系统是 windows 8。我是 PHP 或任何服务器端编程的新手。

如果你们都可以帮助我,也许会发送正确的设置等,这将非常有帮助。谢谢大家 :D :)

【问题讨论】:

    标签: php apache xampp localhost


    【解决方案1】:

    你可以使用phpMailer,更简单,更完美。

    您需要下载这两个文件并将它们放在同一个目录中:

    http://goo.gl/TyYgty

    那么您需要/包含class.phpmailer.php

    // change the path of the file
    require_once("_path_to/class.phpmailer.php"); 
    

    完成后,您需要配置phpMailer() 功能设置:

    注意:您需要提供有效的电子邮件,方法是转到您的域 c 面板并创建带有密码的电子邮件,然后将它们添加到下面的配置中,或者您可以使用 Gmail如果您没有主机或域,则作为 host,email,password 而不是电子邮件,但在这种情况下,$mail->Port 将是 Gmail 端口,可能是 465$mail->SMTPSecure 将是 ssl

    $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->SMTPDebug = 1;
            $mail->SMTPAuth = true;
            $mail->SMTPSecure = "http";
            $mail->Host = "your webmail host domain"; // ex. webmail@domain.com
            $mail->Port = 25;
            $mail->Username = "sender email goes here"; // ex. info@domain.com
            $mail->Password = "sender email password goes here";
            $webmaster_email = "sender email goes here"; // ex. info@domain.com
            $mail->From = $webmaster_email;  
            $mail->FromName = "sender name goes here"; // ex. John Doe
            $mail->AddAddress($email);  
            $mail->AddReplyTo($webmaster_email); 
            $mail->IsHTML(true);
            $mail->Subject = "your message subject goes here";
            $mail->Body = 'your message body goes here'; // take a look on google, how to send html email body
    
            if(!$mail->Send())  
            {  
                echo 'An error occurred, Please try again later';
            }else {
                echo 'Email Sent!';
            }
    

    那么你就可以随时随地使用它了,localhost/webserver

    【讨论】:

      【解决方案2】:

      检查您的 Gmail 安全身份验证,因为 Gmail 不允许从低安全性应用程序进行登录访问,因此应在 gmail 中启用这些设置,如下所示。

      1. 转到我的帐户中的“不太安全的应用”部分。

      2. “访问安全性较低的应用程序”旁边,选择开启

      【讨论】:

        猜你喜欢
        • 2015-12-16
        • 2012-05-07
        • 2014-12-03
        • 2013-07-15
        • 2012-01-21
        • 1970-01-01
        • 2012-12-15
        • 2012-10-19
        • 2013-04-06
        相关资源
        最近更新 更多