marciofmjr
5/4/2018 - 1:20 AM

PHPMailer

Using PHPMailer in hostgator

<?php
include("PHPMailer/PHPMailerAutoload.php");

$mail = new PHPMailer;
$mail->isSMTP(); 
$mail->Host = 'mail.domain.com.br';
$mail->SMTPAuth = true;
$mail->Username = 'some-email@domain.com.br';
$mail->Password = 'password here';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

$mail->setFrom('some-email@domain.com.br', 'Domain Name');
$mail->addAddress('receiver-email@domain.com.br');
$mail->isHTML(true);

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

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