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;
$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
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.]
JFactory::getApplication()->enqueueMessage(json_encode(['email' => $email, 'contt' => $contt, 'sender' => $sender, 'body' => $body, 'send' => $send]), 'notice');
at the bottom of your function?