Mailer test mail not successful Topic is solved

Need help with the Administration of your Joomla! 5.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
User avatar
N6REJ
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Sun Nov 27, 2005 9:25 am
Location: Ponca City, OK
Contact:

Mailer test mail not successful

Post by N6REJ » Mon Feb 26, 2024 8:48 pm

I have a client having an issue with the mailer not functioning properly. We've spent many hours troubleshooting and getting no results. I could really use some help sorting this out.
Just some relative info...
Mailer setup is a pretty core Joomla function. It should be unaffected by plugins, etc. (read "should" as "I would expect so but there is no guarantee because these are complex systems").
Joomla's Mail class is a "wrapper" around a well-known library called PHPMailer. The wrapper adds some Joomla-specific functionality to that of PHPMailer.
I've traced the flow into Joomla's mail class to the point where it does the send. All it returns is "false", which indicates a failure. Normally there's some kind of error message associated with a failure like this, but in this case there's nothing.
I set the debugging level for both Joomla and PHPMailer up to the maximum, and still all we got was "false". This is really not helpful.
I wrote a little test program that used PHPMailer directly, using the server settings we used in Joomla, and asked it to send me a test message. This worked just fine.
We also tried with Membership Pro disabled, just in case that was causing the problem. No change.
It is possible that we missed a plugin that is somehow interrupting the mail process, but there's nothing I'm aware of. Membership Pro uses the core Joomla mail functions, so it's not that.
Bear

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17417
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Mailer test mail not successful

Post by toivo » Mon Feb 26, 2024 9:06 pm

Is the email domain of the 'From Email' the same as the domain of the web server?

Did the client's host recommend particular SMTP settings to be used? Is the host restricting the outgoing SMTP connections to their own mail servers?

Follow this tutorial to the letter and the SMTP dialogue will hopefully reveal the reason: How to debug SMTP mail in Joomla 4
Toivo Talikka, Global Moderator

User avatar
N6REJ
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Sun Nov 27, 2005 9:25 am
Location: Ponca City, OK
Contact:

Re: Mailer test mail not successful

Post by N6REJ » Tue Feb 27, 2024 7:46 pm

Yes, the host and I both have gone over and tested the mailer functions. As stated in the original posts there is nothing even happening according to test code when the send button is pressed.
When the testing instructions are followed there is no log generated.

A direct call to PHPMailer with the same settings as in the mail server config section worked just fine.
Here's the code that was used to test the mailer directly.

Code: Select all

<?php
error_reporting(E_ALL);

require_once 'libraries/vendor/autoload.php';

use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Timeout = 30;
$mail->Host = 'mail.****.com';
$mail->Username = 'web@****.com';
$mail->Password = '******';
$mail->SMTPDebug = 4;
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->setFrom('web@****.com', '**** Website');
$mail->addAddress('support@******.com');
$mail->Subject = "PHPMailer test";
$mail->Body = 'this is a test.';
$result = $mail->send();
echo "sent!";
var_dump($result);
All the passwords, etc. Are obscured of course
Bear

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17417
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Mailer test mail not successful

Post by toivo » Tue Feb 27, 2024 9:28 pm

There are three alternatives of the Mailer in the Mail section of the Server tab, PHP Mail, Sendmail and SMTP. Was SMTP selected in Joomla?
Toivo Talikka, Global Moderator

User avatar
N6REJ
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Sun Nov 27, 2005 9:25 am
Location: Ponca City, OK
Contact:

Re: Mailer test mail not successful

Post by N6REJ » Tue Feb 27, 2024 9:34 pm

yes, neither php nor smtp function
Bear

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17417
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Mailer test mail not successful

Post by toivo » Wed Feb 28, 2024 4:28 am

As you mentioned, Joomla calls the PHPMailer methods through a wrapper, the Joomla Mail class, but there are also a number of other Joomla classes that check and prepare the parameters, before the actual send() method is called in PHPMailer.

The test mail is sent by the class MailTemplate, which loads the mail template from the database table _mail_templates. If the row with template_id 'com_config.test_mail' does not exist, MailTemplate::send() returns false before trying to call PHPMailer::send(). Could that be the case here?
Toivo Talikka, Global Moderator

tamiwhiteside
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Feb 29, 2024 10:28 pm

Re: Mailer test mail not successful

Post by tamiwhiteside » Fri Mar 01, 2024 8:01 pm

I have this same issue.

User avatar
N6REJ
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Sun Nov 27, 2005 9:25 am
Location: Ponca City, OK
Contact:

Re: Mailer test mail not successful

Post by N6REJ » Mon Mar 04, 2024 6:10 am

This situation was solved when we discovered the mail template itself was missing. How that occured I've no idea but the client reports all is well now that we replaced the missing template. What is really strange is we had done a "reinstall core files" and that had not cured it.
Bear

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17417
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Mailer test mail not successful

Post by toivo » Mon Mar 04, 2024 7:35 am

Good to hear that the issue has now been resolved!

The reinstallation of core files is unlikely to touch the mail templates because they are in the database. However, a missing mail template should trigger an error message that explains what happened. I will report the message 'false' as a bug in the Joomla! Issue Tracker and hope to justify a more descriptive message as a fix.
Toivo Talikka, Global Moderator


Post Reply

Return to “Administration Joomla! 5.x”