mb_send_mail

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

mb_send_mail锟斤拷锟酵憋拷锟斤拷锟斤拷锟斤拷始锟�

说锟斤拷

mb_send_mail ( string $to , string $subject , string $message [, string $additional_headers = NULL [, string $additional_parameter = NULL ]] ) : bool

锟斤拷锟斤拷锟绞硷拷锟斤拷锟绞硷拷头锟斤拷锟斤拷锟捷革拷锟斤拷 mb_language() 锟斤拷锟斤拷锟斤拷转锟斤拷锟斤拷锟诫。 锟斤拷锟斤拷 mail() 锟斤拷一锟斤拷锟斤拷装锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷渭锟� mail()锟斤拷

锟斤拷锟斤拷

to

锟斤拷锟斤拷锟酵碉拷锟斤拷锟绞硷拷锟斤拷址锟斤拷锟斤拷通锟斤拷锟斤拷锟脚分革拷锟斤拷址锟斤拷 to 锟斤拷指锟斤拷锟斤拷锟斤拷占锟斤拷恕锟� 锟矫诧拷锟斤拷锟斤拷锟结被锟皆讹拷锟斤拷锟诫。

subject

锟绞硷拷锟斤拷锟解。

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.

Note:

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.

Note:

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 锟斤拷一锟斤拷 MTA 锟斤拷锟斤拷锟叫诧拷锟斤拷锟斤拷 锟斤拷使锟斤拷 sendmail 时锟斤拷锟斤拷锟斤拷锟斤拷确锟侥凤拷锟斤拷路锟斤拷头锟斤拷锟叫帮拷锟斤拷锟斤拷

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.

锟斤拷锟斤拷值

锟缴癸拷时锟斤拷锟斤拷 TRUE锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE锟斤拷

锟轿硷拷

  • mail() - 锟斤拷锟斤拷锟绞硷拷
  • mb_encode_mimeheader() - 为 MIME 头锟斤拷锟斤拷锟街凤拷锟斤拷
  • mb_language() - 锟斤拷锟斤拷/锟斤拷取锟斤拷前锟斤拷锟斤拷锟斤拷