Example 1. Sending mail.
mail("joecool@example.com", "My Subject", "Line 1nLine 2nLine 3"); |
|
Example 2. Sending mail with extra headers.
mail("nobody@example.com", "the subject", $message,
"From: webmaster@$SERVER_NAMErn"
."Reply-To: webmaster@$SERVER_NAMErn"
."X-Mailer: PHP/" . phpversion()); |
|
Example 3. Sending mail with extra headers and setting an additional command
line parameter.
mail("nobody@example.com", "the subject", $message,
"From: webmaster@$SERVER_NAME", "-fwebmaster@$SERVER_NAME"); |
|
You can also use simple string building techniques to build complex email
messages.
Example 4. Sending complex email.
/* recipients */
$to = "Mary " . ", " ; // note the comma
$to .= "Kelly ";
/* subject */
$subject = "Birthday Reminders for August";
/* message */
$message = '
Birthday Reminders for August
Here are the birthdays upcoming in August!
| Person | Day | Month | Year |
| Joe | 3rd | August | 1970 |
| Sally | 17th | August | 1973 |
';
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
/* additional headers */
$headers .= "From: Birthday Reminder rn";
$headers .= "Cc: birthdayarchive@example.comrn";
$headers .= "Bcc: birthdaycheck@example.comrn";
/* and now mail it */
mail($to, $subject, $message, $headers); |
|
NewSourceMedia is providing links to these listings as
a courtesy, and makes no representations regarding the content or
any information related thereto. Any questions, complaints or claims
regarding the downloaded content or details must be directed to the appropriate
publisher. We do not encourage or condone the use of any
software in violation of applicable laws.