0
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 1; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.yahoo.com'; // Specify main and backup SMTP servers
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myemail'; // SMTP username
$mail->Password = 'mypass'; // SMTP password
// $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = '[email protected]';
$mail->FromName = 'abc';
$mail->addAddress('[email protected]'); // Name is optional
//$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
// $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
我也嘗試過Gmail,但它一直給我錯誤SMTP連接()失敗。SMTP連接()失敗phpmailer
這裏是
2015-05-16 07:28:09 CLIENT -> SERVER: EHLO localhost
2015-05-16 07:28:09 CLIENT -> SERVER: AUTH LOGIN
2015-05-16 07:28:10 CLIENT -> SERVER: bWF0ZWVuX3VsX2hhcUB5YWhvby5jb20=
2015-05-16 07:28:10 CLIENT -> SERVER: c2hhaGlkYWZyaWRpMW1hcmNoMTk5MQ==
2015-05-16 07:28:11 SMTP ERROR: Password command failed: 501 Syntax error in arguments
2015-05-16 07:28:11 SMTP Error: Could not authenticate.
2015-05-16 07:28:11 CLIENT -> SERVER: QUIT
2015-05-16 07:28:11 SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
消息無法發送的錯誤。
郵寄程序錯誤:SMTP connect()失敗。
這裏還有幾個類似這個問題的其他問題。你檢查了他們嗎? – Masiorama
@Masiorama是的,看到他們都沒有工作 –
@ Mateen-ul-haq更改您的Gmail密碼。您剛剛公開了您的帳戶詳細信息。 – Phylogenesis