怎麼使用PHPMailer實現郵件的發送??,phpmailer郵件_PHP教程

來源:互聯網
上載者:User

怎麼使用PHPMailer實現郵件的發送??,phpmailer郵件


來源:http://www.ido321.com/1103.html

發送郵件是常用的功能,LZ今天在項目中也碰到了,特此分享一下。

首先,去下載PHPMailer

1、https://github.com/dwqs/PHPMailer

2、http://download.csdn.net/detail/u011043843/8063583

下載之後,將檔案解壓到項目目錄的對應位置,將class.phpmailer.php和class.smtp.php引入項目中,看代碼:(解壓的檔案不要刪除,否則不行)

// 必要匯入  require("class.phpmailer.php");  require("class.smtp.php");  date_default_timezone_set('Asia/Shanghai');//設定時區東八區$mail = new PHPMailer(); //建立郵件發送類$address = "15602277510@163.com";$mail->IsSMTP(); // 使用SMTP方式發送$mail->CharSet ="UTF-8";//設定編碼,否則發送中文亂碼$mail->Host = "smtp.qq.com"; // 您的企業郵局網域名稱$mail->SMTPAuth = true; // 啟用SMTP驗證功能$mail->Username = "461147874@qq.com"; // 郵局使用者名稱(請填寫完整的email地址)$mail->Password = "**********"; // 郵局密碼$mail->From = "461147874@qq.com"; //郵件寄件者email地址$mail->FromName = "dwqs";$mail->AddAddress($address, "dwqs");//收件者地址,可以替換成任何想要內送郵件的email信箱,格式是AddAddress("收件者email","收件者姓名")//$mail->AddReplyTo("", "");//$mail->AddAttachment("/var/tmp/file.tar.gz"); // 添加附件//$mail->IsHTML(true); // set email format to HTML //是否使用HTML格式$mail->Subject = "驗證郵件"; //郵件標題$mail->Body = "Hello,這是測試郵件"; //郵件內容$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; //附加資訊,可以省略if(!$mail->Send()) {        echo 'Mailer Error: ' . $mail->ErrorInfo;    } else {   echo "Message sent!恭喜,郵件發送成功!";    }?>

測試結果:



下一篇:你的大學,有多少遺憾?


在本地使用phpmailer發送郵件需要怎配置?


php使用phpmailer發送郵件不成功

伺服器沒有SMTP
 

http://www.bkjia.com/PHPjc/899960.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/899960.htmlTechArticle怎麼使用PHPMailer實現郵件的發送??,phpmailer郵件 來源:http://www.ido321.com/1103.html 發送郵件是常用的功能,LZ今天在項目中也碰到了,特此...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.