使用PHPMail傳送郵箱(163郵箱為例)

2021-09-07 09:41:09 字數 1665 閱讀 6113

2、建立index.html檔案。並寫入**。

標 題:

內 容:

3、建立index.php檔案並寫入**。(首先引入class.phpmailer.php和class.smtp.php這兩個類檔案)

<?php 

include "class.phpmailer.php";

include "class.smtp.php";

$mail = new

phpmailer();

$mail->issmtp();//

使用smtp服務

$mail->charset = "utf8";//

編碼格式為utf8,不設定編碼的話,中文會出現亂碼

$mail->host = "smtp.163.com";//

傳送方的smtp伺服器位址

$mail->smtpauth = true;//

是否使用身份驗證

$mail->username = "***[email protected]";//

傳送方的163郵箱使用者名稱

$mail->password = "***x";//

傳送方的郵箱密碼,注意用163郵箱這裡填寫的是「客戶端授權密碼」而不是郵箱的登入密碼!

$mail->smtpsecure = "ssl";//

使用ssl協議方式

$mail->port = 994;//

163郵箱的ssl協議方式埠號是465/994

$mail->form= "***x";

$mail->helo= "***x";

$mail->setfrom("***[email protected]","***x");//

設定發件人資訊,如郵件格式說明中的發件人,這裡會顯示為mailer(***[email protected]),mailer是當做名字顯示

$mail->addaddress($_post['mail'],'liang');//

設定收件人資訊,如郵件格式說明中的收件人,這裡會顯示為liang([email protected])

$mail->ishtml(true

);

$mail->subject = $_post['sub'];//

郵件標題

$mail->body = $_post['con'];//

郵件正文

if(!$mail->send())else

?>

4、完成後就能傳送郵件了!

注意:1、163、qq等郵箱埠不一樣。應填寫相應的埠。

2、需開啟pop3/smtp/imap服務,如圖所示。(獲取授權密碼)

3、所填密碼為授權密碼。不是登入密碼。

4、確保extension=php_openssl.dll開啟(在php.ini中設定),將前面的分號去掉。

此時完成郵件傳送

使用php mail函式通過465埠傳送郵件

由於專案需要,必須支援php使用原生mail函式實現郵件傳送 所以暫時拋棄使用郵件類,linuxmail等解決方案 在網上搗鼓半天sendmail,網上的資料翻了遍,都沒找到很好的解決方法 由於伺服器封禁了25埠,必須要通過465傳送郵件 最後終於找到了使用postfix的可行方法,這裡記錄一下問題...

使用node 傳送郵箱通知

use strict const nodemailer require nodemailer const moment require moment nodemailer.createtestaccount err,account 填入自己的賬號和密碼 let transporter nodemai...

Flask Mail使用163郵箱非同步傳送郵件

很多態別的應用程式都需要在特定事件發生時提醒使用者,而常用的通訊方法是電子郵件。雖然 python 標準庫中的 smtplib 包可用在 flask 程式中傳送電子郵件,但包裝了 smtplib 的 flask mail 擴充套件能更好地和 flask 整合。使用 pip 安裝 flask mail...