function send_mail($message, $subject)
{
if (array_key_exists('resume', $_FILES))
{
$uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['resume']['name']));
if (move_uploaded_file($_FILES['resume']['tmp_name'], $uploadfile))
{
require './PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 1;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "XXXX";
$mail->SetFrom('[email protected]', 'ABC');
$mail->AddAddress('[email protected]');
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->AltBody = 'This is a plain-text message body';
$mail->addAttachment($uploadfile);
if ($mail->Send())
{
echo "<script>alert('Your application is sent successfully. Our recruitment team will get in touch with you soon.');</script>";
}
else
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
else
{
echo 'Failed to move file to ' . $uploadfile;
}
}
我得到下面提到的錯誤:
CLIENT -> SERVER: EHLO localhost
CLIENT -> SERVER: STARTTLS
CLIENT -> SERVER: EHLO localhost
CLIENT -> SERVER: AUTH LOGIN
CLIENT -> SERVER: ZGV0ZWN0aW9uaW5zdHJ1bWVudEBnbWFpbC5jb20=
CLIENT -> SERVER: ZGV0ZWN0aW9uaW5kaWE=
SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuk534-5.7.14 PHxasqAG-1Yi0Ij1bFvZdQIBCbXiwU2i-qOUAnhhTN-mHhCHRat1ivgXGVmBuQTk0cJTl2534-5.7.14 7kvt6yrXWWs9R8Rz1mxkje545Mg0F7Xx3Cl1VTW33gDBxGfcVfR-pIVPd1SIqMHWdICkLz534-5.7.14 pPL3_DNms_IS8jJkz3Eo3MH91Yq1OU3XUV1EXzfxaUA7xbYyK9jbwM1XVvVQ-NqqYYKCMY534-5.7.14 uNWA9kWIDl_XXYWrNNP6_cCiWomH8> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 bb5sm14055457pac.21 - gsmtp
SMTP錯誤:無法驗證。 客戶端 - >服務器:退回 SMTP connect()失敗。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 郵件錯誤:SMTP連接()失敗。
如果您按照鏈接到錯誤消息的故障排除指南中的建議進行操作,您會有更多想法。對於一個開始設置'SMTPDebug = 2',這樣你就可以看到服務器消息。 – Synchro