我用的是win10 和 WampServer
php mail()函數(shù)在windows中是不能直接使用的,需要安裝sendmail,假如是用的XAMPP,則已經(jīng)下載好,不需要重新下載
1.下載sendmail.zip 地址:http://glob.com.au/sendmail/
2.下載成功后解壓,并把下載好的文件剪切至wamp目錄(其實(shí)存到哪里都一樣這里為了方便存就放在wamp下好了,和www在同一目錄)
3.配置php.ini 和剛剛下載的 sendmail/sendmail.ini
①php.ini
搜索[mail function]關(guān)鍵字找到如下代碼
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.qq.com ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from =798932948@qq.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path ="E:wampwamp64sendmailsendmail.exe -t"
SMTP = 郵箱smtp地址 (例:QQ郵箱是smtp.qq.com l63郵箱是smtp.163.com )
sendmail_from = 你對(duì)應(yīng)郵箱的郵件地址(例:QQ郵箱)
sendmail_path = 下載的sendmail中sendmail.exe的地址(例:E:wampwamp64sendmailsendmail.exe -t)
注意:去掉sendmail_path 前的分號(hào),這里分號(hào)表示注釋的意思
改完之后重啟服務(wù)器配置才會(huì)生效
②sendmail.ini
因?yàn)槲沂怯肣Q郵箱,QQ郵箱不能直接使用密碼,要使用QQ授權(quán)碼
(什么是QQ郵箱授權(quán)碼?)
[sendmail] ; you must change mail.mydomain.com to your smtp server smtp_server=smtp.qq.com smtp_port=25 auth_username=798932948@qq.com auth_password=QQ郵箱授權(quán)碼 force_sender=798932948@qq.com
4.然后就可以用php中的mail()發(fā)送郵件了
例子localhost/mail.php
<?php $to = "收件人郵箱賬號(hào)"; $subject = "THEME";//主題 $message = "Hello Email";//郵件內(nèi)容 $from = "798932948@qq.com"; $headers = "From: $from"; $result = mail($to,$subject,$message,$headers); var_dump($result); ?>
當(dāng)前文章:PHPmail()本地郵箱服務(wù)器搭建全過(guò)程
文章路徑:http://jinyejixie.com/article16/cjoodg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、網(wǎng)站收錄、標(biāo)簽優(yōu)化、外貿(mào)建站、服務(wù)器托管、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容