PHP
  • Introduction
  • PHPMailer
  • UploadFile
  • PHP link MySQL to insert
  • rand功能
  • Create GUID by random
  • Coding problem
  • PHP+MySQL樹狀圖
  • JWT(Json Web Token)
  • 小功能
    • array_push
    • array_chunk
  • 遞迴
  • 生成json
  • 註解方式
  • Call API
  • google url shortener
  • 身分證字號驗證
  • google maps api 取兩點路線規劃的距離
  • 兩點座標的直線距離
  • 將傳入的陣列重新根據某個欄位做排序
  • 抓取最準的IP,從近到遠做判斷
  • 利用curl推播ios,用ios的token
  • 在local端onServer
Powered by GitBook
On this page
  • 先由右方取得PHPMailer,下載完畢後解壓再把class.phpmailer.php、class.smtp.php二個類別檔拷貝出來點我下載
  • 使用前注意事項

Was this helpful?

PHPMailer

PreviousIntroductionNextUploadFile

Last updated 5 years ago

Was this helpful?

先由右方取得PHPMailer,下載完畢後解壓再把class.phpmailer.php、class.smtp.php二個類別檔拷貝出來

使用前注意事項

  1. 使用PHPmailer時,PHP 必須安裝 OpenSSL 的擴充程式。 最好使用php 5以上,因為php 4 ,有OpenSSL的bug…,然後phpmailer 使用2.1 以上版本for php 5/6。關於openssl的安裝方式可以參考一下這篇文章 「[php安裝openssl的方法](/href="

  2. 使用 PHPMailer 透過 Gmail 帳號寄信時,需要採用安全性較低的登入技術,所以要開啟安全性較低的應用程式存取權限,您可以在登入 Gmail 帳號後由開啟,否則會造成「send-mail: Authorization failed 534 5.7.14」認證錯誤。

  3. 開發測試時建議您可以開啟 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= new PHPMailer(); //建立新物件
$mail->IsSMTP(); //設定使用SMTP方式寄信
$mail->SMTPAuth = true; //設定SMTP需要驗證
$mail->SMTPSecure = "ssl"; // Gmail的SMTP主機需要使用SSL連線
$mail->Host = "smtp.gmail.com"; //Gamil的SMTP主機
$mail->Port = 465;  //Gamil的SMTP主機的埠號(Gmail為465)。
$mail->CharSet = "utf-8"; //郵件編碼

$mail->Username = "xxxx@gmail.com"; //Gamil帳號
$mail->Password = "password"; //Gmail密碼

$mail->From = $Mail; //寄件者信箱
$mail->FromName = "線上客服"; //寄件者姓名

$mail->Subject ="一封線上客服信";  //郵件標題
$mail->Body = "姓名:".$Name."信箱:".$Mail."主題:".$Subject."回應內容:".$Sendbody; //郵件內容

$mail->IsHTML(true); //郵件內容為html ( true || false)
$mail->AddAddress("who@mail.com.tw"); //收件者郵件及名稱

if(!$mail->Send()) {
    echo "發送錯誤: " . $mail->ErrorInfo;
} else {
    echo "感謝您的回覆,我們將會盡速處理!";
}
點我下載
http://blog.yogo.tw/2009/08/phpopenssl.html)」。
https://www.google.com/settings/security/lesssecureapps