Send mail using Mail.php / PEAR

To send mail using Mail.php, PEAR will have to be uploaded to the site.  If you would like to manually install PEAR, find the instructions below.  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, a .user.ini, a test script named zsend.php and a script to show the server path to /PEAR named zpath.php.  The PEAR directory also contains a web.config to prevent browser access to the subdirectory.
 
To use Mail.php, upload the /PEAR directory and the .user.ini to the document root of the site ( /site/wwwroot/ ).  If you have an existing .user.ini, update it with the include_path to /PEAR.
 
 
Testing Mail.php
 
zsend.php may be used to test whether Mail.php has been properly set up.  Open the file in a text editor and update the settings highlighted in red below.
 
<html>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once "Mail.php";
$from = "Sender <postmaster@domain.com>";
$to = "Recipient <postmaster@domain.com>";
$subject = "Mail.php test email";
$body = "Test email sent using Mail.php.";
$host = "sm##.internetmailserver.net";
$username = "postmaster@domain.com";
$password = "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);
echo "Mail.php test"
?>
</html>
 
Once updated, 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, the path to PEAR in the user.ini and/or the zsend.php settings should be reviewed.  For the former, see the next section.
 
To prevent abuse, zsend.php should be deleted from the site after testing.
 
 
Server path to /PEAR
 
Please note that the server path to the site root has been in flux for Windows Azure Pack, so you may need to review it after uploading the included .user.ini.  Or if Mail.php were to stop working in the future, you may need to check if the server path has been updated by Microsoft.
 
To review the server path to the /PEAR directory, upload zpath.php to the document root ( /site/wwwroot ) then view zpath.php in a browser.  If the server path has changed, update it in the .user.ini.  After reviewing the path, zpath.php should be deleted.