emails not sent from controller

by wbdevlop   Last Updated October 08, 2019 06:10 AM - source

I'm using a function on my controller to send email but emails are not sends my code is :

function sendestimation()
    {
        $jinput = JFactory::getApplication()->input;
        $email = $jinput->get('email');
        $contt = $jinput->get('contt');

        $mailer = JFactory::getMailer();

        $config = JFactory::getConfig();
        $sender = array( 
            $config->get( 'mailfrom' ),
            $config->get( 'fromname' ) 
        );


        $recipient = $email;

        $mailer->addRecipient($recipient);

        $body   = $contt;
        $mailer->isHtml(true);
        $mailer->Encoding = 'base64';
        $mailer->setBody($body);

        $send = $mailer->Send();
        if ( $send !== true ) {
            echo 'Error sending email: ';
        } else {
            echo 'Mail sent';
        }

    }

I'm getting Error sending email as output that mean the email not send and also in my inbox no email

Tags : joomla-3.x


Answers 1


The default CMD filter used by Joomla\Input\Input::get() strips out @ character from the email address resulting in invalid address. Use a different filter like STRING to keep the character.

$email = $jinput->get('email', null, 'STRING');
Sharky
Sharky
October 08, 2019 06:05 AM

Related Questions