Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > แก้ปัญหาการส่งอีเมลหลังจากอัพเกรดจาก PHP Version 5.4 ไปเป็น 5.6 โดยใช้ New PHPMailer



 
Clound SSD Virtual Server

แก้ปัญหาการส่งอีเมลหลังจากอัพเกรดจาก PHP Version 5.4 ไปเป็น 5.6 โดยใช้ New PHPMailer

ตอนนี้ผมสามารถใช้ PHPMailer บน PHP Version 5.6 ได้แล้วนะครับ รายละเอียดตามด้านล่างครับ

1. ดาวโหลด PHPMailer new version (https://github.com/PHPMailer/PHPMailer)
2. เขียนสคริปในการส่งตามด้านล่าง

Code (PHP)
<?php 

session_start();

require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/SMTP.php';
require 'PHPMailer/src/OAuth.php';
require 'PHPMailer/src/POP3.php';



$email = '[email protected]';
$password = 'xxxxxxxx';
$subject = 'Testing PHP Mailer on PHP Version 5.6';
$strMessage = 'PHP Version 5.6, SMTP Gmail ';
$strTo = '[email protected]';

?>

<?php

$mail = new PHPMailer(true);
$contextOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false
    )
);
try{
    $mail->IsHTML(true);
    $mail->IsSMTP();
    $mail->SMTPDebug = 2;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 587;
    $mail->Username = $email;
    $mail->Password = $password;
    $mail->SetFrom($email);
    $mail->Subject = $subject;
    $mail->Body = $strMessage;
    $mail->AddAddress($strTo);
    $mail->send();
} catch (Exception $e) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}

?>
<html>
<head>
<title>PHPMailer Sending Email</title>
</head>
<body>
</body>
</html>


3. ในหน้าเว็บจะมีการแสดงข้อมูลการส่งตามด้านล่าง
Code
2018-05-19 12:29:05 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP h28-v6sm9488908pgn.65 - gsmtp
2018-05-19 12:29:05 CLIENT -> SERVER: EHLO xxxxxx
2018-05-19 12:29:05 SERVER -> CLIENT: 250-smtp.gmail.com at your service, xxxxxx SMTPUTF8
2018-05-19 12:29:05 CLIENT -> SERVER: STARTTLS
2018-05-19 12:29:06 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2018-05-19 12:29:06 CLIENT -> SERVER: EHLO xxxxx
2018-05-19 12:29:06 SERVER -> CLIENT: 250-smtp.gmail.com at your service, xxxxxx SMTPUTF8
2018-05-19 12:29:06 CLIENT -> SERVER: AUTH LOGIN
2018-05-19 12:29:06 SERVER -> CLIENT: 334 xxxx
2018-05-19 12:29:06 CLIENT -> SERVER: <credentials hidden>
2018-05-19 12:29:06 SERVER -> CLIENT: 334 xxxx
2018-05-19 12:29:06 CLIENT -> SERVER: <credentials hidden>
2018-05-19 12:29:06 SERVER -> CLIENT: 235 2.7.0 Accepted
2018-05-19 12:29:06 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2018-05-19 12:29:06 SERVER -> CLIENT: 250 2.1.0 OK h28-v6sm9488908pgn.65 - gsmtp
2018-05-19 12:29:06 CLIENT -> SERVER: RCPT TO:<[email protected]>
2018-05-19 12:29:06 SERVER -> CLIENT: 250 2.1.5 OK h28-v6sm9488908pgn.65 - gsmtp
2018-05-19 12:29:06 CLIENT -> SERVER: DATA
2018-05-19 12:29:06 SERVER -> CLIENT: 354 Go ahead h28-v6sm9488908pgn.65 - gsmtp
2018-05-19 12:29:06 CLIENT -> SERVER: Date: Sat, 19 May 2018 19:29:05 +0700
2018-05-19 12:29:06 CLIENT -> SERVER: To: [email protected]
2018-05-19 12:29:06 CLIENT -> SERVER: From: [email protected]
2018-05-19 12:29:06 CLIENT -> SERVER: Subject: Testing PHP Mailer on PHP Version 5.6
2018-05-19 12:29:06 CLIENT -> SERVER: Message-ID: <[email protected]>
2018-05-19 12:29:06 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.5 (https://github.com/PHPMailer/PHPMailer)
2018-05-19 12:29:06 CLIENT -> SERVER: MIME-Version: 1.0
2018-05-19 12:29:06 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1
2018-05-19 12:29:06 CLIENT -> SERVER:
2018-05-19 12:29:06 CLIENT -> SERVER: PHP Version 5.6, SMTP Gmail
2018-05-19 12:29:06 CLIENT -> SERVER:
2018-05-19 12:29:06 CLIENT -> SERVER: .
2018-05-19 12:29:07 SERVER -> CLIENT: 250 2.0.0 OK 1526732947 h28-v6sm9488908pgn.65 - gsmtp
2018-05-19 12:29:07 CLIENT -> SERVER: QUIT
2018-05-19 12:29:07 SERVER -> CLIENT: 221 2.0.0 closing connection h28-v6sm9488908pgn.65 - gsmtp


4. หากทำตามขั้นตอนเหล่านี้แล้วยังส่งไม่ได้ให้ตรวจสอบความปลอดภัยอีเมล @gmail ที่ใช้ authen ว่ามีการเปิด อนุญาตแอปที่มีความปลอดภัยน้อย เข้าถึงแล้วหรือยัง

Code
---------
this is GMail issue
---------
read this Google Help (https://support.google.com/mail/answer/14257?p=client_login&rd=1)

1. Open your web browser and sign in to Gmail at http://mail.google.com/mail. If you see a word verification request, type the letters in the distorted picture and finish signing in.
2. Close your browser and try accessing your messages in your email client again.
3. If you're still having problems, visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in with your Gmail username and password. If necessary, enter the letters in the distorted picture.
4. Click Continue.
5. Restart your mail client and try accessing messages in your email client again.

ที่มา: https://stackoverflow.com/questions/3949824/smtp-error-could-not-authenticate-in-phpmailer


หากมีข้อผิดพลาดประการ ต้อง ขอ อภัยไว้ ณ ที่นี้ ด้วยครับ







   
Share
Bookmark.   

  By : lnw Yod
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2018-05-19
  Download : No files
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่