php本地主机邮件未使用xampp发送


php localhost mail not getting sent using xampp

我已经按照其他人的指示配置了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

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

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

您可以更容易地使用phpMailer,而且效果非常好。

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

http://goo.gl/TyYgty

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

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

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

注意:您需要提供一封有效的电子邮件,方法是转到域c面板并创建一封带有密码的电子邮件,然后将它们添加到下面的配置中,或者如果您没有主机或域,则可以将Gmail用作hostemailpassword而不是电子邮件,但在这种情况下,$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

检查你的Gmail安全身份验证,因为Gmail不允许从低安全应用程序登录,所以应该在Gmail中启用这些设置,如下所示。

  1. 转到我的帐户中的"不太安全的应用程序"部分。

  2. "访问不太安全的应用程序"旁边,选择打开