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

My code:

function sendestimation()
    $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é à support@myemail.com utilisant SMTP. Vérifier que vous avez reçu l'e-mail de test.

[The email has been sent to support@myemail.com 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 – mickmackusa Oct 8 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? – mickmackusa Oct 8 at 22:40

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. – mickmackusa Oct 8 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é à support@myemail.com utilisant SMTP. Vérifier que vous avez reçu l'e-mail de test. – wbdevlop Oct 8 at 16:01

Your Answer

