Pages

Wednesday, July 26, 2017

Send EMAIL with PHPMailer using SMTP in bluehost

<?php
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once "Phpmailer/PHPMailerAutoload.php";


$mail = new PHPMailer(true);
$mail-> IsSMTP();
$mail->Host = "box605.bluehost.com";
$mail->SMTPAuth = true;
$mail->Username = "email@domain.com";
$mail->Password = 'password';
//$mail->SMTPSecure = 'tls'; //TLS
$mail->Port = 26;

//$mail->From = "";//$mail->Username; //mandatory and identical to Username property
$mail->setFrom($mail->Username, 'Mailer Test');
$mail->addReplyTo('email@domain.com');

$mail->Subject = "Hello message";
$mail->Body = "Body goes here...";
$mail->addAddress('zakeerio25@gmail.com');



if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}

?>