使用 PHPMailer 發送郵件,phpmailer發送郵件_PHP教程

來源:互聯網
上載者:User

使用 PHPMailer 發送郵件,phpmailer發送郵件


轉載 http://blog.csdn.net/liruxing1715/article/details/7914974

PHPMailer 的官方網站:http://phpmailer.worxware.com/

PHPMailer 最新類庫下載地址:【點擊下載】

PHPMailer GitHub 下載地址:https://github.com/Synchro/PHPMailer,該頁面也提供了使用例子,不過不是很全面。

使用方法,詳見代碼清單:

header('Content-Type:text/html;Charset=utf-8');
require './PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // 設定郵件使用SMTP
$mail->Host = 'mail.wanzhao.com'; // 郵件伺服器地址
$mail->SMTPAuth = true; // 啟用SMTP身分識別驗證
$mail->CharSet = "UTF-8"; // 設定郵件編碼
$mail->setLanguage('zh_cn'); // 設定錯誤中文提示
$mail->Username = 'wanzhao@wanzhao.com'; // SMTP 使用者名稱,即個人的郵箱地址
$mail->Password = 'www123456'; // SMTP 密碼,即個人的郵箱密碼
$mail->SMTPSecure = 'tls'; // 設定啟用加密,注意:必須開啟 php_openssl 模組
$mail->Priority = 3; // 設定郵件優先順序 1:高, 3:正常(預設), 5:低
$mail->From = 'liruxing@wanzhao.com'; // 寄件者郵箱地址
$mail->FromName = '李茹星'; // 寄件者名稱
$mail->addAddress('liruxing1715@163.com', 'Lee'); // 添加接受者
$mail->addAddress('ellen@example.com'); // 添加多個接受者
$mail->addReplyTo('info@example.com', 'Information'); // 添加回複者
$mail->addCC('liruxing1715@sina.com'); // 添加抄送人
$mail->addCC('512848303@qq.com'); // 添加多個抄送人
$mail->ConfirmReadingTo = 'liruxing@wanzhao.com'; // 添加發送回執郵件地址,即當收件者開啟郵件後,會詢問是否發生回執
$mail->addBCC('734133239@qq.com'); // 添加密送者,Mail Header不會顯示密送者資訊
$mail->WordWrap = 50; // 設定自動換行50個字元
$mail->addAttachment('./1.jpg'); // 添加附件
$mail->addAttachment('/tmp/image.jpg', 'one pic'); // 添加多個附件
$mail->isHTML(true); // 設定郵件格式為HTML
$mail->Subject = 'Here is the 主題';
$mail->Body = 'This is the HTML 資訊 body in bold!. Time:'.date('Y-m-d H:i:s');
$mail->AltBody = 'This is the 主體 in plain text for non-HTML mail clients';

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

echo 'Message has been sent';

http://www.bkjia.com/PHPjc/954467.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/954467.htmlTechArticle使用 PHPMailer 發送郵件,phpmailer發送郵件 轉載http://blog.csdn.net/liruxing1715/article/details/7914974 PHPMailer 的官方網站:http://phpmailer.worxware.com/ PHP...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.