Friday, June 19, 2009

PHP Send Email Using SMTP

include("Mail.php");
/* mail set
up recipients, subject etc */
$recipients = "email addresses of all to, cc & bcc recipients";
$headers["From"] = "sender;
$headers["To"] = "emails adresses for to field";
$headers
["Subject"] = "ema
il subject";
$mailmsg = "Html body of mail";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "host name of smtp for local system localhost is used";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "smtpusername";
$smtpinfo["password"] = "smtpPassword";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>

No comments:

Post a Comment