We can easily send email in joomla using $mailer = JFactory::getMailer(); which invoke jMail class. It returns a reference to the JMail object.Below is the code which define how to send an email in joomla.
-Invoke JMail Class
$mailer = JFactory::getMailer();
-Set sender array so that from name will show in your inbox
$mailer->setSender($from);
-this can be a single address or an array of addresses of recipient
$mailer->addRecipient($to);
-Set subject of your email
$mailer->setSubject($subject);
-set content of your email
$mailer->setBody($body);
-If you would like to send as HTML, include this line; otherwise, leave it out
$mailer->isHTML();
-if attachment required in email
$mailer->addAttachment($file);
-Send once you have set all of your options
$mailer->send();
0 Comment(s)