UnixServerAdmin

Server Administration & Management

PHP Mailing Script – 1

<?php
require_once “Mail.php”;

$from = “name Sender <mail@domain.com>”;
$to = “name Recipient <mail@domain.com>”;
$subject = “Hi!”;
$body = “Hi,nnHow are you?”;

$host = “mail.domain.com”;
$username = “smtp_username”;
$password = “smtp_password”;

$headers = array (‘From’ => $from,
‘To’ => $to,
‘Subject’ => $subject);
$smtp = Mail::factory(‘smtp’,
array (‘host’ => $host,
‘auth’ => true,
‘username’ => $username,
‘password’ => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo(“<p>” . $mail->getMessage() . “</p>”);
} else {
echo(“<p>Message successfully sent!</p>”);
}
?>

Advertisements

March 25, 2011 - Posted by | PHP |

1 Comment »

  1. This is certainly a excellent write-up. Thanks a lot for taking the time to detail this all out for folks. It really is a great help!

    Comment by Ashanti Rosky | June 15, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: