= 4.0.6, PHP 5, PHP 7, PHP 8)mb_send_mail — 發(fā)送編碼過(guò)的郵件說(shuō)明mb_send_mail( string $to, string $subject, string $message, stri">

mb_send_mail

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_send_mail發(fā)送編碼過(guò)的郵件

說(shuō)明

mb_send_mail(
    string $to,
    string $subject,
    string $message,
    string $additional_headers = null,
    string $additional_parameter = null
): bool

發(fā)送郵件。郵件頭和內(nèi)容根據(jù) mb_language() 設(shè)置來(lái)轉(zhuǎn)換編碼。 這是 mail() 的一個(gè)包裝器函數(shù),所以詳情參見(jiàn) mail()

參數(shù)

to

被發(fā)送到該郵件地址??赏ㄟ^(guò)逗號(hào)分隔地址的 to 來(lái)指定多個(gè)收件人。 該參數(shù)不會(huì)被自動(dòng)編碼。

subject

郵件標(biāo)題。

message

郵件消息。

additional_headers(可選)

String to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). Validate parameter not to be injected unwanted headers by attackers.

注意:

When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.

Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

注意:

If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably ? qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with ? RFC 2822.

additional_parameter

additional_parameter 是一個(gè) MTA 命令行參數(shù)。 在使用 sendmail 時(shí)對(duì)設(shè)置正確的返回路徑頭很有幫助。

This parameter is escaped by escapeshellcmd() internally to prevent command execution. escapeshellcmd() prevents command execution, but allows to add addtional parameters. For security reason, this parameter should be validated.

Since escapeshellcmd() is applied automatically, some characters that are allowed as email addresses by internet RFCs cannot be used. Programs that are required to use these characters mail() cannot be used.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false

參見(jiàn)