 |
[มือใหม่] PHPmailer ไม่สามารถส่ง mail ไปได้ ช่วยด้วยครับ |
|
 |
|
|
 |
 |
|
ลองดูแบบนี้ครับ
Code (PHP)
require_once '../class.phpmailer.php';
$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch
try {
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif'); // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
|
 |
 |
 |
 |
Date :
2014-11-25 17:18:56 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้อ่ะ หรือผมไปตั้งค่าอะไรผิดหรือเปล่าครับ ใน php.ini อะครับ มีตัวอย่างให้ดูหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2014-11-25 17:43:03 |
By :
aofficially |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ต้องครับ ปกติถ้าส่งไม่ได้มันจะมี Error Message แจ้งครับ
|
 |
 |
 |
 |
Date :
2014-11-26 09:02:08 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมใส่ $mail->ErrorInfo; ไว้ที่ echo ตัวแรก
มันมี เออเร้อ SMTP Error: Could not connect to SMTP host.
ผมต้องแก้ยังไงฮะ แล้วสาเหตุมันเกิดจากอะไรได้บ้างครับ
|
 |
 |
 |
 |
Date :
2014-11-26 09:57:03 |
By :
aofficially |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเทสในlocalhostหรือhostจริงครับ แนะนำให้เทสบนhostจริง
|
 |
 |
 |
 |
Date :
2014-12-02 21:48:22 |
By :
matay107 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|