php發送郵件(方法一)_PHP教程

來源:互聯網
上載者:User
[html]
1. 執行個體:
[html]
1. $content ="ceshi";
2. $technicalemail="www.2cto.com";
3. $headers = "From: =?utf-8?B?".base64_encode('chenglong')."?= <$technicalemail>\r\n";
4.
5. $content = strip_tags($content);
6. $a = @mail($technicalemail,'=?utf-8?B?'.base64_encode('出錯提交').'?=',$content,$headers);
7. if($a)
8. {
9. echo '郵件發送成功!';
10. }
通過mail()函數發送:
1,需要配置php.ini郵件資訊
開啟php.ini設定檔,配置紅色的位置
; For Win32 only.
SMTP = localhost ---如果本機裝了sendmail,這個表示使用本地郵件伺服器,也可以是ip地址,還有伺服器網域名稱
smtp_port = 25 ---連接埠號碼
; For Win32 only.
;sendmail_from = www.2cto.com ---可寫可不寫 把這裡的分號去掉
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path = ----郵件伺服器的路徑
2.mail()函數
mail()函數允許從指令碼直接寄送電子郵件
mail()函數返回的是boolean值,成功返回true,失敗返回flase

mail(to,subject,message,headers,paeameters);

to --必需,規定郵件的接收者
subject --必需,規定郵件的主題,該參數不能包含任何換行字元
message --必需,規定要發送的訊息
headers --可選,規定額外的前序,比如from,Cc以及Bcc 可以參考一些資料
parameters --可選,規定sendmail程式的額外參數
3. php.ini 中 將extension=php_imap.dll前面的“;”去掉

作者:Vericlongmore

http://www.bkjia.com/PHPjc/478152.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478152.htmlTechArticle[html] 1.span style=font-size:18px;執行個體:/span [html] 1. $content =ceshi; 2. $technicalemail=www.2cto.com; 3.$headers = From: =?utf-8?B?.base64_encode(chenglong).?= $technicalemai...

  • 聯繫我們

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