Function name: mb_send_mail()
Applicable version: PHP 4 >= 4.0.6, PHP 5, PHP 7
Usage: The mb_send_mail() function is used to send multibyte character-encoded emails. It is a function provided by the mbstring extension and needs to be enabled in the PHP configuration file.
Syntax: bool mb_send_mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
parameter:
Return value: Return true when sending the email successfully, and false when sending it fails.
Example:
$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 "邮件发送失败!"; }
In the example above, we specify the recipient's email address, email subject, email content, and sender's email address. When sending emails using the mb_send_mail() function, you can also specify additional header information through the additional_headers parameter, such as the sender's name, cc, and secret delivery. The additional_parameters parameter is used to pass additional parameters to sendmail, such as specifying the sender's email address.
Note that to ensure that the mb_send_mail() function works properly, you need to enable the mbstring extension in your PHP configuration file.