1. 程式人生 > >PHP傳送163郵件

PHP傳送163郵件

郵件包下載地址: https://github.com/PHPMailer/PHPMailer 程式碼: // 引入PHPMailer的核心檔案 include "PHPMailer-master/src/PHPMailer.php"; include "PHPMailer-master/src/SMTP.php"; header("content-type:text/html;charset=utf8"); $mail = new PHPMailer(); $mail->IsSMTP(); //設定要傳送郵件 $mail->IsHTML(TRUE); //是否允許要傳送html程式碼 $mail->CharSet = 'UTF-8'; //設定文字格式 $mail->SMTPAuth = TRUE; //是否需要身份驗證 $mail->From = "郵箱賬號@163.com"; $mail->FromName = "郵件名"; $mail->Host = "smtp.163.com"; //傳送郵件的服務協議地址 $mail->Username = "使用者名稱"; //使用者名稱 $mail->Password = "授權碼"; //授權碼 $mail->Port = 25; //發郵件埠號預設25 $mail->AddAddress("收件人郵箱地址"); //收件人 $mail->Subject = "……"; //標題 $mail->Body = "……"; //內容 if ($mail->send()){ echo "傳送成功"; }else{ echo "傳送失敗"; }