|
|
|
ช่วยด้วยครับพี่ๆ ผมจะทำ php send mail smtp google แต่มันเออเร่อ ช่วยดูหน่อยครับผม |
|
|
|
|
|
|
|
Username gmail ผมไปตั้งค่า เปิด Allow less secure apps: ON ก็เปิดแล้วครับ
PHPMeiler ผมก็โหลดมาลงเครื่อง server ผมแล้ว
Code (PHP)
require_once('PHPMailer/PHPMailerAutoload.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo("[email protected]","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML(true);
$address = "[email protected]";
$mail->AddAddress($address, "John Doe");
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
แต่มัน error แบบนี้ครับ
2017-03-08 03:47:22 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP g27sm2444995pgn.20 - gsmtp 2017-03-08 03:47:22 CLIENT -> SERVER: EHLO pointblankdev-th.com 2017-03-08 03:47:22 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [103.233.194.57] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-03-08 03:47:22 CLIENT -> SERVER: STARTTLS 2017-03-08 03:47:22 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2017-03-08 03:47:22 CLIENT -> SERVER: EHLO pointblankdev-th.com 2017-03-08 03:47:22 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [103.233.194.57] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-03-08 03:47:22 CLIENT -> SERVER: AUTH LOGIN 2017-03-08 03:47:22 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2017-03-08 03:47:22 CLIENT -> SERVER: Ym16cHJvamVjdEBnbWFpbC5jb20= 2017-03-08 03:47:23 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2017-03-08 03:47:23 CLIENT -> SERVER: YmFuazI1Mzk= 2017-03-08 03:47:23 SERVER -> CLIENT: 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 g27sm2444995pgn.20 - gsmtp 2017-03-08 03:47:23 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 g27sm2444995pgn.20 - gsmtp 2017-03-08 03:47:23 SMTP Error: Could not authenticate. 2017-03-08 03:47:23 CLIENT -> SERVER: QUIT 2017-03-08 03:47:23 SERVER -> CLIENT: 221 2.0.0 closing connection g27sm2444995pgn.20 - gsmtp 2017-03-08 03:47:23 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
ผมต้องแก้อะไรเพิ่มครับ
Tag : PHP
|
|
|
|
|
|
Date :
2017-03-08 10:50:47 |
By :
errordev |
View :
1571 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เหมือนว่า Account จะมีปัญหาครับ ลอง Login ผ่าน Web Browser ตามที่มันแนะนำครับ
|
|
|
|
|
Date :
2017-03-08 11:09:10 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยผมหน่อย 2 วันแล้ว ติดตรงนี้ละครับ
|
|
|
|
|
Date :
2017-03-09 00:57:48 |
By :
errordev |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไฟล์ไม่ครบครับ
|
|
|
|
|
Date :
2017-03-13 10:11:42 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|