Fast2Host Logo

Scripting

PHP Mail with PEAR

This is the recommended way of sending emails using PHP and PEAR on windows servers:


<?php

require_once "Mail.php";



$from = "russell <russell@fast2host.net>";

$to = "russell <russell@fast2host.net>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";



$host = "mail.YOUR-DOMAIN.COM";

$username = "russell@fast2host.net";

$password = "EMAIL 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>");

 }

?>



Maintain peace of mind with UK based support

Email any time or call 01480 26 00 00 014 80 26 00 00