Mail

Official Documentation: https://docs.joomla.org/Sending_email_from_extensions

The Joomla Mail class extends PHPMailer so look the parent class to see other useful methods like clearAddresses() etc.

https://github.com/joomla/joomla-cms/blob/staging/libraries/vendor/phpmailer/phpmailer/class.phpmailer.php

https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php

$mailer = JFactory::getMailer();
$mailer->setSender([$from_email,$from_name]);
$mailer->addRecipient($recipient); // will take single email address or array of emails
$body   = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
$mailer->setSubject('Your subject string');
$mailer->setBody($body);
$mailer->addAttachment($filepath);
$send = $mailer->Send();
if ( $send !== true ) {
    echo 'Error sending email: ';
} else {
    echo 'Mail sent';
}

Attachments with Filenames

See Discussion: https://github.com/joomla/joomla-cms/issues/14285

// You have to pass the file path as the first argument and the name as the second,
// these can either be a single string or an array (and if an array they must both contain the same number of elements).

$mailer = JFactory::getMailer();
$mailer->addAttachment($filepath, $filename);

// Or

$mailer = JFactory::getMailer();
$mailer->addAttachment([$filepath], [$filename]);

Further Reading: