作者: dreamfly 分类: linux,php 发布时间: 2016-11-28 00:00

// multiple recipients
$to  '' ', '// note the comma
$to .= '';

// subject
$subject 'Birthday Reminders for August';

// message
$message '
  <title>Birthday Reminders for August</title>
  <p>Here are the birthdays upcoming in August!</p>

// To send HTML mail, the Content-type header must be set
$headers  'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

// Additional headers
$headers .= 'To: Mary <>, Kelly <>' "\r\n";
$headers .= 'From: Birthday Reminder <>' "\r\n";
$headers .= 'Cc:' "\r\n";
$headers .= 'Bcc:' "\r\n";

// Mail it

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

  • additional_headers (optional)

  • 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). If outside data are used to compose this header, the data should be sanitized so that no unwanted headers could be injected.


    additional_headers does not have mail header injection protection. Therefore, users must make sure specified headers are safe and contains headers only. i.e. Never start mail body by putting multiple newlines.


    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