<?php
require_once "Mail.php";
$from = "Susan Sender <sender@example.com>";
$to = "Rachel Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtpcorp.com";
// Enter 'ssl://' and your SMTP2GO account's SMTP server.
$port = "465";
// 8465 can also be used.
$username = "smtp_username";
$password = "smtp_password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'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>");
}
?>
Tuesday, 1 October 2013
PHP Script to Send Email Using SMTP Authentication and SSL Encryption
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment