Last active
October 17, 2016 06:09
-
-
Save Yiannistaos/dbfe9aee98908c2dd31638a1a99962b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send Email | |
function sendEmail($email_recipient = '', $subject = 'The mail subject goes here...', $body = 'The mail body goes here..') | |
{ | |
$mailer = JFactory::getMailer(); | |
$config = JFactory::getConfig(); | |
$sender = array($config->get('fromname'), $config->get('mailfrom')); | |
$email_recipient = (!empty($email_recipient)) ? $email_recipient : $config->get('mailfrom'); | |
$mailer->setSender($sender); | |
$mailer->setSubject($subject); | |
$mailer->isHTML(true); | |
$mailer->Encoding = 'base64'; | |
$mailer->setBody($body); | |
$mailer->addRecipient($email_recipient); | |
$send = $mailer->Send(); | |
if ($send !== true): | |
mail($email_recipient, "Error sending email:", "Error sending email: ".$send->__toString()); | |
endif; | |
} | |
// How to use the function | |
sendEmail("your@email.com", "Email subject goes here...", "Body text goes here..."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment