Joomla content management system allows users to send emails from Joomla extensions. You can take advantage of this feature and send emails to anyone you wish, right from the Joomla extensions. This blog post will help you how to send emails from Joomla extensions in easy steps.
$config =JFactory::getConfig(); $sender = array( $config->getValue( 'config.mailfrom' ), $config->getValue( 'config.fromname' ) ); $mailer->setSender($sender);
$user = JFactory::getUser(); $recipient = $user->email; $mailer->addRecipient($recipient);
1. Plain Text Mail
$body = "Your body stringnin double quotes if you want to parse the nnewlines etc"; $mailer->setSubject('Your subject string'); $mailer->setBody($body); // Optional file attached $mailer->addAttachment(JPATH_COMPONENT.DS.'assets'.DS.'document.pdf');
2. HTML Format Mail
$body = '<h2>Our mail</h2>' . '<div>A message to our dear readers' . '<img src="cid:logo_id" alt="logo"/></div>'; $mailer->isHTML(true); $mailer->Encoding = 'base64'; $mailer->setBody($body); // Optionally add embedded image $mailer->AddEmbeddedImage( JPATH_COMPONENT.DS.'assets'.DS.'logo128.jpg', 'logo_id', 'logo.jpg', 'base64', 'image/jpeg' );
$send = $mailer->Send(); if ( $send !== true ) { echo 'Error sending email: ' . $send->message; } else { echo 'Mail sent'; }
Follow the above steps carefully to send emails from Joomla extensions. If you are unable to send mails successfully or get an error message, Request a Quote. Our Joomla team of experts will assist you to send emails from Joomla extensions.
We also develop custom Joomla extensions. Ask for designing a Joomla extension to send mails easily. You may also check our Joomla store for more useful extensions for your website.