Powered by InterCreatives | Site Map
Search:
NewSourceMedia Popular Tutorials: PHP Javascripts Web Hosting
SoftwareTutorials
CATEGORIES
Job Listings
 
Home / PHP / Communication

Sending Email with PHP

Published by: php.net


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!

PersonDayMonthYear
Joe3rdAugust1970
Sally17thAugust1973
'; /* 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);


Next PHP Page:
1  2  [3]  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32 





Hosting by iPowerWeb.com - 50 Gb for $7.95