I'm using a custom function in my controller to send emails, but the emails are not being sent.

My code:

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;


    $body   = $contt;
    $mailer->Encoding = 'base64';

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


I'm getting:

Error sending email

so the email is not being sent and there is no email sent to my inbox.

I have tried Joomla's send email test and received:

L'e-mail a bien été envoyé à [email protected] utilisant SMTP. Vérifier que vous avez reçu l'e-mail de test.

[The email has been sent to [email protected] using SMTP. Check that you have received the test e-mail.]

  • What php version are you on and what exact Joomla version are you on? You should display all of the variables that you are generating/using to ensure that they all hold the intended values. Beyond that basic diagnostic technique, this stream of chatter may help you progess: forum.joomla.org/viewtopic.php?t=968659 and a blog post from toivo: talikka.com/joomla/… and another tutorial Oct 8, 2019 at 22:16
  • After implementing Sharky's advice, can you tell us what you get if you write JFactory::getApplication()->enqueueMessage(json_encode(['email' => $email, 'contt' => $contt, 'sender' => $sender, 'body' => $body, 'send' => $send]), 'notice'); at the bottom of your function? Oct 8, 2019 at 22:40

1 Answer 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');
  • You may want to mention something here so that researchers don't use an incorrect technique. Oct 8, 2019 at 11:56
  • I tried the solution on that answer but still no email send I did try send email test -> L'e-mail a bien été envoyé à [email protected] utilisant SMTP. Vérifier que vous avez reçu l'e-mail de test.
    – wbdevlop
    Oct 8, 2019 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.