JFactory/getMailer
From Joomla! Documentation
< JFactory
Returns a reference to the global mail object, only creating it if it doesn't already exist. The object returned will be of type JMail.
Syntax
object JMail getMailer()
Example
In this example, a test email is sent to the email address of the site owner.
$mail =& JFactory::getMailer(); $config =& JFactory::getConfig(); $mail->addRecipient( $config->getValue( 'config.mailfrom' ) ); $mail->setSubject( 'Test message' ); $mail->setBody( 'This is an example email to test the Joomla! JFactory::getMailer() method. Please ignore it' ); if ($mail->Send()) { echo "Mail sent successfully."; } else { echo "An error occurred. Mail was not sent."; }
