phpmailer PHP郵件 的用法

2022-09-16 20:21:10 字數 1110 閱讀 9705

第二,確認你的伺服器系統已經支援socket ,通過phpinfo();檢視是否支援sockets(socket 是屬於php擴充套件部分),如果顯現為「enabled」,那就是支援了。

第三,把檔案解壓到你的web伺服器目錄下,呼叫類就可以了.

首先包含class.phpmailer.php,然後建立物件,設定引數,呼叫成員函式。具體請見下面的示例**:

例項1,做成函式方便呼叫

<?php    

require("phpmailer/class.phpmailer.php");

function smtp_mail( $sendto_email, $subject, $body, $extra_hdrs, $user_name

)

else

}

//引數說明(傳送到, 郵件主題, 郵件內容, 附加資訊, 使用者名稱)

smtp_mail("[email protected]", "歡迎使用phpmailer!", "null", "yourdomain.com", "username");

?>

要注意的內容:

1. 郵件的字符集設定, $mail->charset = "gb2312";            //

這裡指定字符集!在這裡我只指定為gb2312因為這樣outlook能正常顯示郵件主題,我嘗試過設為utf-8但在outlook下顯示亂碼。

2. 如果是傳送html格式的郵件,那麼記得也指定

3. 如果你想用它來**郵件的話,記得修改包含檔案函式,如:

require("phpmailer/class.phpmailer.php");

改為 require_once("phpmailer/class.phpmailer.php");

否則的話會產生類的重定義。

以上**是引用

經過下午的使用,個人認為要使用phpmailer,

首先需要有乙個郵件伺服器

php的 mail函式沒有指定,應該是使用的php設定的smtp

而在這裡需要具體指定

同時需要指定郵件伺服器的管理者和密碼

郵件的傳送

問題描述 當hr發布乙個緊急需求的時候,會向所有的員工傳送一條關於本次緊急需求詳情的郵件。嘗試解決方案 net傳送郵件 system.net.mail.mailmessage message new system.net.mail.mailmessage aa 126.com bb 126.com ...

用Spring的郵件抽象層傳送郵件

1 mimemessagehelper包裝類 public class messagewraper public mimemessagehelper getmessagehelper public messagewraper mimemessage message,mimemessagehelper...

Python郵件與CentOS郵件

背景 由於專案需要對每日資料進行比對監控,所以需要把比對結果傳送給各負責人,本文記錄下python傳送郵件的幾個步驟。需要模組 smtplib pip install smtplib閒言少敘上 coding utf 8 from email.header import header from ema...