Send mail using Mail.php / PEAR

To send mail using Mail.php, PEAR and a .user.ini with the path to PEAR need to be uploaded to the site.  Instructions are included below to manually install PEAR.  If you require assistance with installing PEAR, please open a ticket with the Support Department.
 
 
Download PEAR.zip

 
Inside the .zip is the PEAR directory, which contains a web.config to prevent browser access, a test script zsend.php, and both a .user.ini and user.ini.  The file used depends on the server and version of PHP, if not sure which is applicable, uploading both won't cause any issues.  For brevity, the steps below always reference the latter.
 
 
Update and upload .user.ini and PEAR directory
 
If the site has an existing .user.ini, it will need to be updated with the server path to the PEAR directory.  If the site does not have a .user.ini, the example file included in PEAR.zip may be used after replacing "FTPusername" with the FTP username for your site account.
 
For reference, the Path to root is found in the Site Info pane of the Winhost Control Panel.
 
 
Upload the /PEAR directory and the updated .user.ini to the document root of the site to use Mail.php.
 
 
Testing Mail.php
 
zsend.php may be used to test Mail.php.  First update the settings in the script highlighted in red below.
 
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once "Mail.php";
$from = "[email protected]";
$to = "[email protected]";
$subject = "Mail.php test email";
$body = "Test email sent using Mail.php.";
$host = "m##.internetmailserver.net";
$username = "[email protected]";
$password = "password";
$headers = array ('Date' => date('r'),
  'From' => $from,
  'To' => $to,
  'Subject' => $subject,
  'Message-ID' => '<' . time() . md5($from . $to) . '@domain.com>');
$smtp = Mail::factory('smtp',
  array ('localhost' => $host,
  'host' => $host,
  'auth' => true,
  'username' => $username,
  'password' => $password));
$mail = $smtp->send($to, $headers, $body);
echo "Mail.php test"
?>
 
After updating, save the changes and upload the script to the site.  View the page in a browser and you should see "Mail.php test" returned.  If the email is not received, review the path to PEAR in the .user.ini and/or the zsend.php settings.
 
To prevent abuse, zsend.php should be deleted from the site after testing.