Wednesday, May 23, 2007

Example for php sending email

<?
$to = "johndate@computer.com";
$subject = "Hello!";
$body = "John,\n\nHow are you doing?";

if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>


A simple email using MIME protocol:

From: "David Willson"
To: "John Date"
Subject: Just Say Hi!
Date: Fri, 28 Feb 2003 18:12:32 -0400
Message-ID:
MIME-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit;

Hi David! How are you doing?

What is MIME?

MIME is a protocol.
MIME stands for multipurpose internet mail extensions.

How to send email via PHP

Sorry! PHP cannot send email itself.
To send email, PHP must use the MIME protocol.