校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > php5.5使用PHPMailer-5.2發送郵件的完整步驟

php5.5使用PHPMailer-5.2發送郵件的完整步驟

熱門標簽:企業400電話辦理多少費用 桂陽公司如何做地圖標注 合肥企業外呼系統線路 萍鄉商鋪地圖標注 代理打電話機器人 電信外呼系統多少錢一個月 神龍斗士電話機器人 宿州正規外呼系統軟件 太原400電話申請流程

前言

這幾天一直被郵件發送功能搞得頭大,作為一個小白,遇到坑總是難免的。今天終于把phpmailer搞定了,下面就來總結一下

PHPMailer - A full-featured email creation and transfer class for PHP。

在PHP環境中可以使用PHPMailer來創建和發送郵件。

最新版本(20181012)是PHPMailer 6.0.5,這個無法兼容php5.5以下的環境。由于我需要維護php5.3的項目,需要切換到PHPMailer5.2來發送郵件。

下載地址: https://github.com/PHPMailer/PHPMailer/releases/tag/v5.2.24

下面話不多說了,來一起看看詳細的介紹吧

基本使用

下載解壓后。新建一個測試demo。

?php
require 'PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->SMTPDebug = 3;        // Enable verbose debug output

$mail->isSMTP();          // Set mailer to use SMTP
$mail->Host = 'smtp.exmail.qq.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true;        // Enable SMTP authentication
$mail->Username = 'xxx@qq.com';     // SMTP username
$mail->Password = 'yourpassword';       // SMTP password
$mail->SMTPSecure = 'ssl';       // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;         // TCP port to connect to

$mail->setFrom('fromWho@qq.com', 'Mailer');
$mail->addAddress('toWhom@qq.com', 'Ryan Miao');  // Add a recipient
$mail->addAddress('ellen@example.com');    // Name is optional
// $mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

$mail->addAttachment('/var/tmp/file.tar.gz');   // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true);         // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body b>in bold!/b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
 echo 'Message could not be sent.';
 echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
 echo 'Message has been sent';
}

開啟SMTPDebug可以查看日志

 `0` No output
 `1` Commands
 `2` Data and commands
 `3` As 2 plus connection status
 `4` Low-level data output

錯誤信息保存在 $mail->ErrorInfo對象中。

保存為mail.php, 命令行執行

php mail.php

即可看到日志,以及郵件發送成功。

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

您可能感興趣的文章:
  • PHPMailer使用教程(PHPMailer發送郵件實例分析)
  • PHPMailer郵件類利用smtp.163.com發送郵件方法
  • phpmailer簡單發送郵件的方法(附phpmailer源碼下載)
  • phpmailer在服務器上不能正常發送郵件的解決辦法
  • 使用php發送有附件的電子郵件-(PHPMailer使用的實例分析)
  • Linux服務器下PHPMailer發送郵件失敗的問題解決
  • PHPMailer郵件發送的實現代碼
  • PHPMailer發送HTML內容、帶附件的郵件實例
  • 163的郵件用phpmailer發送(實例詳解)
  • PHP使用PHPMailer發送郵件的簡單使用方法

標簽:辛集 白銀 鄂州 廊坊 衡陽 崇左 綏化 太原

巨人網絡通訊聲明:本文標題《php5.5使用PHPMailer-5.2發送郵件的完整步驟》,本文關鍵詞  php5.5,使用,PHPMailer-5.2,發送,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《php5.5使用PHPMailer-5.2發送郵件的完整步驟》相關的同類信息!
  • 本頁收集關于php5.5使用PHPMailer-5.2發送郵件的完整步驟的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 广元市| 绥江县| 大名县| 临桂县| 佛冈县| 孟州市| 铁岭市| 大理市| 定襄县| 肥城市| 谷城县| 垣曲县| 茶陵县| 陆丰市| 乌拉特中旗| 河南省| 深泽县| 柯坪县| 隆安县| 武平县| 武冈市| 汾西县| 通山县| 崇左市| 勐海县| 女性| 邯郸县| 竹山县| 安平县| 秦皇岛市| 中方县| 赫章县| 西充县| 莱州市| 宣武区| 瑞安市| 莱芜市| 广安市| 厦门市| 崇义县| 旺苍县|