Current Location: Home> Function Categories> mb_send_mail

mb_send_mail

Send encoded emails
Name:mb_send_mail
Category:Multi-byte string
Programming Language:php
One-line Description:Send multibyte character-encoded emails

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:

  • to: Required, specify the recipient's email address.
  • subject: Required, specify the subject of the message.
  • message: Required, specify the content of the message.
  • additional_headers: Optional, specify additional header information, such as From, Cc, or Bcc. The header information should be separated by line breaks\r\n.
  • additional_parameters: Optional, specifying the additional parameters passed to sendmail.

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.

Similar Functions
Popular Articles