本文目錄一覽:
- 1、請問如何配置php.ini發送郵件
- 2、mail()函數發送郵件,php.ini 應該怎樣去配置?
- 3、如何配置php.ini實現讓mail函數實現發送郵件功能
- 4、求PHP中mail函數的使用。要求通過配置php.ini完成
- 5、如何配置PHP.ini 中 sendmail
請問如何配置php.ini發送郵件
一般的linux系統中的主機Sendmail服務都是正常啟動的。你要在php.ini裏面配置的[mail
function],你就加上以下這個,然後試試看,其實,如果你要叫IXwebhosting的客服給你放上php.ini這個文件的話,這個語句默認就有的。
查看原帖
mail()函數發送郵件,php.ini 應該怎樣去配置?
你設置的QQ郵件服務器需要SMTP認證,而PHP內建的mail函數不支持SMTP認證
兩種解決辦法:
其一,找一個不需要SMTP認證的郵件服務器
其二,使用類似於pear mail這種支持SMTP認證的擴展庫
如何配置php.ini實現讓mail函數實現發送郵件功能
找到extension=php_mailparse.dll把前面的「;」去掉。
2.界面代碼展示。
利用的函數 mail()
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )$to
電子郵件收件人,或收件人列表。
本字符串的格式必須符合 ? RFC 2822。例如:user@example.comuser@example.com, anotheruser@example.comUser
User , Another User $subject
電子郵件的主題。$message
所要發送的消息。行之間必須以一個 LF(\n)分隔。每行不能超過 70 個字符。Caution
(Windows 下)當 PHP 直接連接到 SMTP 服務器時,如果在一行開頭髮現一個句號,則會被刪掉。要避免此問題,將單個句號替換成兩個句號。
$message = ‘Birthday Reminders for AugustHere are the birthdays upcoming in August!PersonDayMonthYearJoe3rdAugust1970Sally17thAugust1973’;// To send HTML mail, the Content-type header must be set
求PHP中mail函數的使用。要求通過配置php.ini完成
如果我告訴你,Mail函數在PHP開發中基本用不到,你會怎樣?老實告訴你吧.平常我們用PHP發送郵件,用的不是PHP自帶的Mail函數.而是通過PHP的Socket函數定義自己的一個郵件發送類.現在目前的框架都是這樣處理的.如果想要這個類,請給分之後再郵件我.謝謝!
如何配置PHP.ini 中 sendmail
PHP.ini的配置。
[mail function]
; For Win32 only.
; SMTP = localhost
; smtp_port = 25
; For Win32 only.
; sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
sendmail_path = “D:\PHP5\sendmail\sendmail.exe -t”
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
其實,上面的配置中就那麼么一句是有用的,其它的關掉就可以了。
sendmail_path的用來指定sendmail.exe的路徑,就是上面看到的,『-t』寫上就好,不用管。
接着是sendmail的配置
smtp_server=smtp服務器地址
auth_username=郵箱登錄名
auth_password=郵箱密碼
force_sender=發件人地址全寫
這裡由於沒有自己的STMP服務器,就得用別人的,經測試可以用QQ和163的。例如QQ的smtp_server地址為:smtp.qq.com。auth_username就是登陸名,如果用QQ的就是QQ號碼。auth_password郵箱密碼。force_sender這是其實可以不填。
下面是測試用的PHP代碼:
?php
$to = “123@qq.com”;
$now = date(“Y-m-d h:i:s”);
$from_name = ‘測試者’;
$from_email = ‘Kensy’;
$headers = “From: $from_name $from_email”;
$body = “測試郵件!”;
$subject = “[$now] 測試郵件”;
if (mail($to, $subject, $body, $headers)) {
echo “success!”;
} else {
echo “fail…”;
}
?
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/189396.html