Send Mail in PHP using PHPMailer

How to use PhpMailer with SMTP authentication?

PhpMailer with SMTP Authentication

You can easily send mail through php with SMTP authentication using PhpMailer by following the step given below.
Step 1: First download the PHPMailer script using below direct link.
Step 2:
Download and unzip the php mailer file under public_html folder.
Step 3: Once after extracting the file, your path will be public_html/PHPMailer.
Step 4: Use this PHPMailer script to send mail in your webpage.
Your PHP code will be as we shown below.

require_once ("/home/username/public_html/PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail = new PHPMailer(true);
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->Host = ""; // SMTP server
$mail->Username = ""; // SMTP account username
$mail->Password = "password"; // SMTP account password
$mail->From = "";
$mail->FromName = "Test";
$mail->AddAddress(""); // Receiving Mail ID, it can be either domain mail id (or ) any other mail id i.e., gmail id
$mail->Subject ="PhpMailer script with basic smtp authentication";
$mail->AltBody = " ";
$mail->WordWrap = 80;
$body = "test message";
echo "Mailer Error: " . $mail->ErrorInfo;
echo "Message Sent!";

Note: If you are extracting the PHPMailer_5.2.4 under any name, then your path will be /home/username/public_html/anyname/class.phpmailer.php. The user name you have provided here is your cpanel user name.