首先下載mail.class.php類文件,配置文件中定義下列參數:
- 'MAIL_ADDRESS' => '[email protected]', // 郵箱地址
- 'MAIL_SMTP' => 'smtp.qq.com', // 郵箱SMTP服務器
- 'MAIL_LOGINNAME' => '[email protected]', // 郵箱登錄帳號
- 'MAIL_PASSWORD' => '123456', // 郵箱密碼
- 'MAIL_CHARSET' => 'UTF-8', // 編碼
- 'MAIL_AUTH' => true, // 郵箱認證
- 'MAIL_HTML' => true, // true HTML格式 false TXT格式
在tp項目org中放入mail.class.php,使用時候引入 import('@.ORG.Mail');
- public function index(){
- import('@.ORG.Mail');
- //SendMail('[email protected]','郵件標題','郵件正文','歪酷CMS管理員');
- //解釋下參數: 參數1---目標郵箱, 參數2----郵件標題,參數三--郵件正文,參數四---發件人名稱;
- $content=md5(time());
- session($content,$content);
- $content=C('localurl').'/index.php'.U('Mail/index',array('res'=>$content));
- if(SendMail('[email protected]','nihao郵件標題',$content,'unphp')){
- echo 'chengong';
- }else{
- echo 'shibai';
- }
- $this->display();
- }
另一個頁面接受參數res:
- public function index(){
- header("Content-type: text/html; charset=utf-8");
- $res=I('res');
- echo $res;
- if(session($res)==$res){
- echo '密碼找回成功';
- session($res,null);
- }else{
- echo '已經過期';
- }
- }
新聞熱點
疑難解答
圖片精選