日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php记录邮件发送,有关php邮件发送一点记录

發布時間:2025/3/15 php 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php记录邮件发送,有关php邮件发送一点记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

php郵件發送需要準備2個文件:一個是?class.phpmailer.php',另一個是:class.smtp.php

//文件導入,及參數獲取省去。。。。

$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {

$mail->Host = "smtp.gmail.com"; // SMTP server

$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)

$mail->SMTPAuth = true; // enable SMTP authentication

$mail->SMTPSecure = "ssl"; // sets the prefix to the servier

$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server

$mail->Port = 465; // set the SMTP port for the GMAIL server

$mail->Username ='sgo@gmail.com'; // GMAIL username

$mail->Password = "123456"; // GMAIL password

$mail->AddReplyTo('sgo@gmail.com', 'test');

$mail->AddAddress($email, $username);//根據傳進來的郵件地址參數,發送郵件

$mail->SetFrom('sgo@gmail.com', 'test');

$mail->AddReplyTo('sgo@gmail.com', 'test');

//以上郵箱的配置,qq和gmail都測試過,不過新的qq郵箱會把郵件截住,老的qq郵箱還是挺順暢的。

$mail->Subject = 'Welcome!';

$mail->AltBody = 'Go!'; // optional - MsgHTML will create an alternate automatically

$body ="";

// 郵件的發送大概有2種方式:

一種是直接發送靜態頁面?$mail->MsgHTML(file_get_contents('contents.html'));//$mail->MsgHTML(file_get_contents('views/find.html'));這一種方式發送比較簡潔,不過很難向靜態頁面傳遞參數

另一種是構建body,這一種比較費時,但是容易傳參,一下就構建body的常用格式的一點記錄

$mail->Body="

//在郵件里構建圖片

"

系統自動發送了該郵件

"//一般的文字

"

請點擊://a標簽的寫法,雙引號要轉義

body結束,下面是附件

$mail->AddEmbeddedImage('views/image/you_logo.png',"my-attach"); // 向剛才構建的圖片里嵌入一張圖片,my-attach是cid

//$mail->AddAttachment('images/phpmailer_mini.gif'); //加入附件,附件形式可以是圖片、聲音等等

//$mail->Send();郵件發送

//echo $mail->Send();

if($mail->Send()){

$this->redirect('/simple/send?email='.$email);

}else{

echo "mail test!!!";

}

} catch (phpmailerException $e) {

echo $e->errorMessage(); //Pretty error messages from PHPMailer

} catch (Exception $e) {

echo $e->getMessage(); //Boring error messages from anything else!

}

}

總結

以上是生活随笔為你收集整理的php记录邮件发送,有关php邮件发送一点记录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。