Send email by using PHP

if your ISP need SMTP Authentication
then you need Pear installed for you php5,
and also add one line in your php.ini file:
extension=php_gd2.dll


require_once "Mail.php";

$from = "Sandra Sender ";
$to = "Ramona Recipient ";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "househosting.ca";
$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("

" . $mail->getMessage() . "

");
} else {
echo("

Message successfully sent!

");
}
?>

Comments

Popular posts from this blog

How to install and configure PHP5 with IIS6 on Windows Server 2003 in five easy steps.

How to switch PASV and PORT model in FLAHSGET