helo们我一直试图通过PHP脚本发送邮件过去8天首先我在服务器上使用php mail()它返回false后很多搜索然后公司告诉我他们已禁用此功能和告诉我使用我的Gmail帐户发送邮件然后我google了它,发现phpmailer swiftmailer和其他软件最后我决定使用phpmailer并在我的根文件夹中包含3-4个文件,如此处所述(http://phpmailer.worxware.com/index.php?pg=install#)我用过这个代码
<?php
require("class.phpmailer.php");
include('class.smtp.php');
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->SMTPSecure = 'ssl';
$mail->Username = "myid@gmail.com"; // SMTP account username
$mail->Password = "xxxxxxx"; // SMTP account password
$mail->From = "myid@gmail.com";
$mail->AddAddress("hostimf@gmail.com");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>`
它返回我的firefox浏览器中列出的错误,如此
2015-07-24 20:12:02 CLIENT -> SERVER: EHLO localhost
2015-07-24 20:12:02 CLIENT -> SERVER: AUTH LOGIN
2015-07-24 20:12:03 CLIENT -> SERVER: c2lkZGhhbnRiYWh1Z3VuYUBnbWFpbC5jb20=
2015-07-24 20:12:03 CLIENT -> SERVER: Y2hpbXB1OTQ=
2015-07-24 20:12:04 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 2sm16058566pdp.68 - gsmtp
2015-07-24 20:12:04 SMTP Error: Could not authenticate.
2015-07-24 20:12:04 CLIENT -> SERVER: QUIT
2015-07-24 20:12:04 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message was not sent.Mailer error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting`
这是我在我的wamp服务器上试过的 请帮助我疯狂试图解决这个问题请帮助.....谢谢