How do I use PHPMailer to send emails from my website?

 

Please note: This support article is a guide for our Linux users only.

The following article explains how to use PHPMailer to send emails. PHPmailer makes use of the PHPMailer class and sends the email based on the parameters specified.

To install PHPMailer to your site, please follow these steps:

  1. Download the appropriate version of PHPMailer:
  2. Extract the files into a folder called phpmailer.
  3. Copy the phpmailer folder to the htdocs folder of your website, /vservers/username/htdocs/

When using PHPMailer, you will need to specify the location of the phpmailer folder, typically /vservers/username/htdocs/phpmailer/

Send a Simple Email Message

Below is a sample script you can utilize for PHPmailer:

ini_set("include_path", ".:/vservers/user/htdocs/phpmailer/");
require_once("class.phpmailer.php")
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'mail.example.com';
$mailer->SMTPAuth = true;

$mailer->Username = 'root@example.com';
$mailer->Password = 'Password';
$mailer->FromName = 'Your Name';
$mailer->From = 'user@example.com';
$mailer->AddAddress('recipient@recipientexample.com','Recipient Name');
$mailer->Subject = 'Subject';

$mailer->Body = 'body Text';

if(!$mailer->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mailer->ErrorInfo;
exit;
}

 

Additional information about using PHPMailer can be found at http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html