For Joomla 5+

Joomla calls the PHPMailer methods through a wrapper, the Joomla Mail class. It also calls a number of other Joomla classes that check and prepare the parameters, before the actual send() method is called in PHPMailer.

 

Here is some sample code...

 

//*************
// SEND EMAIL TO MERCHANT
//*************
$mailer = Factory::getMailer();
// Get the Server Sender details....
$config = Factory::getConfig();
$sender = array($config->get('mailfrom'),$config->get('fromname'));
$mailer->setSender($sender);
$mailer->addRecipient($merchant_email);
//  $mailer->addCC(array($cc));
//  $mailer->addBCC(array($bcc));
//  $mailer->addAttachment($attachment);
$mailer->addReplyTo($customer_email, $customer_name);    
$mailer->setSubject("$email_subject - $customer_name");
$mailer->setBody($invoice_body);
$mailer->isHTML(true);
$mailer->Encoding = 'base64';
$send = $mailer->Send();
if(!$send) error_log($send->message); // if it failed, errors to the error log

 

To add another reciepent (To), just add more lines like...

 $mailer->addRecipient( "This email address is being protected from spambots. You need JavaScript enabled to view it." );

 

Reference:

See https://docs.joomla.org/Sending_email_from_extensions (Joomla 3.5)

API Class: https://api.joomla.org/cms-5/classes/Joomla-CMS-Mail-Mail.html