mb_send_mail
發送編碼過的郵件
函數名:mb_send_mail()
適用版本:PHP 4 >= 4.0.6, PHP 5, PHP 7
用法:mb_send_mail() 函數用於發送多字節字符編碼的電子郵件。它是mbstring 擴展提供的函數,需要在PHP 配置文件中啟用該擴展。
語法:bool mb_send_mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
參數:
返回值:成功發送郵件時返回true,發送失敗時返回false。
示例:
$to = "recipient@example.com"; $subject = "测试邮件"; $message = "这是一封测试邮件。"; $headers = "From: sender@example.com"; $additional_parameters = "-f sender@example.com"; if (mb_send_mail($to, $subject, $message, $headers, $additional_parameters)) { echo "邮件发送成功!"; } else { echo "邮件发送失败!"; }
在上面的示例中,我們指定了收件人郵箱地址、郵件主題、郵件內容和發件人郵箱地址。使用mb_send_mail() 函數發送郵件時,還可以通過additional_headers 參數指定額外的郵件頭信息,例如發件人的姓名、抄送、密送等。 additional_parameters 參數用於傳遞給sendmail 的額外參數,例如指定發件人的郵箱地址。
請注意,為了確保mb_send_mail() 函數正常工作,您需要在PHP 配置文件中啟用mbstring 擴展。