Download php mailer from phpmailer site HERE

Download and extract the folder in domain’s required path. If plesk then root folder should be httpdocs.

So path will domain/httpdocs/PHPMailer 5.2.16

Create test php file like send.php and add following code in that.

<?php
date_default_timezone_set('Europe/Madrid');
require_once 'PHPMailer-5.2.16/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2; # 0 off, 1 client, 2 client y server
$mail->CharSet  = 'UTF-8';
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPSecure = 'tls'; # SSL is deprecated
$mail->SMTPOptions = array (
    'ssl' => array(
        'verify_peer'  => true,
        'verify_depth' => 3,
        'allow_self_signed' => true,
        'peer_name' => 'Plesk',
    )
);
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'YOUR_PASSWORD';
$mail->setFrom('[email protected]', 'Name Surname');
$mail->addAddress('[email protected]', 'Name Surname');
$mail->Subject = 'Email subject';
$mail->msgHTML('Email content with html');
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
?>

Once done visit domain/send.php. and check if mails are working.

By anup

Leave a Reply

Your email address will not be published. Required fields are marked *