在註冊的時候,常常會用到郵件驗證,一直想弄明白這是怎麼實現的,記得2年前曾經試過這個問題,沒有實現,今天睏到不行的時候開始決定搞明白這個,然後,然後就出來了。
issmtp(); // 使用smtp方式傳送
$mail->host = "smtp.qq.com"; // 您的企業郵局網域名稱
$mail->smtpauth = true; // 啟用smtp驗證功能
$mail->username = "[email protected]"; // 郵局使用者名稱(請填寫完整的email位址)
$mail->password = "*************"; // 郵局密碼
$mail->port=25;
$mail->from = "[email protected]"; //郵件傳送者email位址
$mail->fromname = "水中的淚";
$mail->addaddress("$address", "a");//收件人位址,可以替換成任何想要接收郵件的email信箱,格式是addaddress("收件人email","收件人姓名")
//$mail->addreplyto("", "");
//$mail->addattachment("/var/tmp/file.tar.gz"); // 新增附件
//$mail->ishtml(true); // set email format to html //是否使用html格式
$mail->subject = "phpmailer測試郵件"; //郵件標題
$mail->body = "hello,這是測試郵件"; //郵件內容
$mail->altbody = "this is the body in plain text for non-html mail clients"; //附加資訊,可以省略
if(!$mail->send())
echo "郵件傳送成功";
phpMailer實現傳送郵件功能
require once phpmailer class.phpmailer.php require once phpmailer class.smtp.php mname this getparam mname cname this getparam cname email this getpar...
PHPMailer實現PHP郵件傳送
2.解壓 從中取出class.phpmailer.php 和 class.smtp.php 放到你的專案的資料夾,因為我們等下會引用到它們.3.建立傳送郵件的函式,其中你需要配置smtp伺服器 function postmail to,subject body else 4.使用函式 postmai...
PHPMailer 郵件傳送
一般有兩個檔案,左邊的資料夾是包含class類檔案等,右邊就是傳送配置檔案 require phpmailer class.phpmailer.php mail new phpmailer mail issmtp mail charset utf 8 mail host smtp.qq.com 這裡...