Enviando e-mail com Joomla

From Basef
Jump to: navigation, search

Use o código abaixo para enviar e-mail dentro do framework do Joomla:

// Make sure all the classes being used are imported
if(!defined('CMSLIB_DEFINED'))
	include_once ( JPATH_BASE. '/components/libraries/cmslib/spframework.php');
 
// Imports JMail library
jimport('joomla.mail.mail');
 
// Gets Joomla configuration
$jconfig = new JConfig();
 
// Gets instance to e-mail object, with everything configured
$mail =& JFactory::getMailer();
 
// Sender
$mail->setSender( $jconfig->mailfrom );
 
// Recipient
$mail->addRecipient( "
 enderecodestinatario@dominio.com" );
 
// Subject
$mail->setSubject( "Assunto do e-mail" );
 
// E-mail content (body)
$mail->setBody( "Conteúdo do e-mail" );
 
// Actually sends the e-mail
$mail->send();