PHPMailer
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
使用PHPmailer時,PHP 必須安裝 OpenSSL 的擴充程式。 最好使用php 5以上,因為php 4 ,有OpenSSL的bug…,然後phpmailer 使用2.1 以上版本for php 5/6。關於openssl的安裝方式可以參考一下這篇文章 「[php安裝openssl的方法](/href="http://blog.yogo.tw/2009/08/phpopenssl.html)」。
使用 PHPMailer 透過 Gmail 帳號寄信時,需要採用安全性較低的登入技術,所以要開啟安全性較低的應用程式存取權限,您可以在登入 Gmail 帳號後由https://www.google.com/settings/security/lesssecureapps開啟,否則會造成「send-mail: Authorization failed 534 5.7.14」認證錯誤。
開發測試時建議您可以開啟 PHPMailer 的 Debug 模式,可以很清楚知道運作的過程,若發生錯誤也可以很快得知問題所在,其語法如下:
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
這邊只提供PHP需要設定的地方的code
include("class.phpmailer.php"); //匯入PHPMailer類別
$Name=$_POST['sndname'];
$Mail=$_POST['sendmail'];
$Subject=$_POST['subject'];
$Sendbody=$_POST['sendbody'];
$mail=