Search Our Database

Send mail using PHP Mailer:

Last updated on |
under |
by

1. Download the PHP Mailer script from Download link.

2. Unzip and upload all the phpmailer source code to your hosting account.

3. Create a mail sending script referring to the following sample:

<?php 
 
require("PHPMailer-master/PHPMailerAutoload.php");
 
$mail = new PHPMailer();
 
$mail->IsSMTP(); // send via SMTP
$mail->Host = "127.0.0.1"; // SMTP servers change to localhost
$mail->Smtp_port ="2525";       // change smtp port
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "email displayed name"; // SMTP username
$mail->Password = "password"; // SMTP password
 
$mail->From = "email@domain.com";
$mail->FromName = "Name";
$mail->AddAddress("Recipient@emailaddress.com","Name");
$mail->AddReplyTo("yourname@domain.com","Your Name");
 
$mail->WordWrap = 50; // set word wrap
 
$mail->IsHTML(true); // send as HTML
 
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML body";
$mail->AltBody = "This is the text-only body";
 
if(!$mail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
 
echo "Message has been sent";
 
?>