Create a new directory mailer and place these phpmailer files in
includes >> mailer
- Exception.php
- OAuth.php
- PHPMailer.php
- POP3.php
- SMTP.php
Now edit your system_load.php from root folder and include PHPMailer class.
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'lib/includes/mailer/Exception.php';
require 'lib/includes/mailer/PHPMailer.php';
$mail = new PHPMailer;
You can include this before these lines
include('lib/includes/localize.php');
include('lib/includes/functions.php');
include('lib/includes/update.php');
Now change your send_mail function with
function send_email($mailto, $subject, $message) {
global $mail;
//getting set email addresses from database.
$from_email = get_option('email_from');
$reply_to = get_option('email_to');
$mail->setFrom($from_email, 'Your business name');
$mail->addAddress($mailto, '');
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $message;
$mail->send();
}
Further things about PHPMailer you may find on their documentation as per your requirements.
thanks. I would not able to help you anything further on this.