Sending mail in Joomla is easy. It can be done by posting the value of form in view to the controller.php of that component.
Function that can be used is
function mail()
{
$fromname = JRequest::getvar('name');
$sender_mail = JRequest::getVar('email');
$recipient = JRequest::getVar('destintation_name');
$recipient_mail = JRequest::getVar('destination_email');
$body = JRequest::getVar('body');
$mailSender =& JFactory::getMailer();
$mailSender ->addRecipient($recipient_mail);
$mailSender ->setSender($sender_mail);
$mailSender->isHTML(true);
$mailSender ->setBody($body);
if (!$mailSender ->Send())
{
echo "error"; // If not Sent
}
else{
$message = JText::_( 'Mail Sent' );
$this->setRedirect('url', $message);
}
}
0 Comment(s)