Thursday, March 6, 2008

How to Send Email from a PHP Script

Send Email from a PHP Script

All it takes is the right configuration (to send mail using a local or a remote server) and one function:

* mail().

Send Email from a PHP Script Example

The first argument to this function is the recipient, the second specifies the message's subject and the third one should contain the body. So to send a simple sample message, we could use:

$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("

Message successfully sent!

");
} else {
echo("

Message delivery failed...

");
}
?>

That's it!


http://email.about.com/cs/phpemailtips/qt/et031202.htm

No comments: