Mautic says 'emails sent', but nothing has actually gone out

Your software
My Mautic version is: v4.4.7
My PHP version is: 8
My Database type and version is: MariaDB 10.3.38-MariaDB

Your problem
My problem is:

Channels>Emails says about 1100 emails have been sent, but nothing actually has gone out - 0 read, 0 bounced emails, etc.

I have been sending emails with this Mautic installation for years, but have never seen this. What could have happened? What should I check to troubleshoot?

I tried a small test mailing to a test segment with 3 of my own addresses. Same result; Mautic says ā€˜sentā€™, but nothing actually gone out. With ā€˜Send Exampleā€™, the email does arrive fine - email configuration still works.

These errors are showing in the log:

Which logā€¦? Looking for it nowā€¦

ā€˜Todayā€™s Mautic error log is empty. Check server error log for error messages Mautic didnā€™t have a chance to catch.ā€™

error_log in the installation folder is empty.

Steps I have tried to fix the problem:

Don 't know where to start yet.

Edit:

Based on this, when Mautic says emails are sent, could it still mean the cronjob hasnā€™t run? Where is the limbo where these emails are stuck?

Could I send emails stuck in limbo with an SSH command? Iā€™ve tried:

php bin/console mautic:emails:send

Something has now gone out. Iā€™ve received one bounce message; it still does not look like a normal full mailing. Why did/do my emails get stuck in spool limbo?

Correct. They were all in the spool.

Thanks. But why were they stuck there? Why didnā€™t they go out? What should I check/fix?

Only one or two emails have gone out now. Most of the mailing was lost, probably deleted from the server after a number of seconds you can set in Mautic configuration?

Mailings worked fine before. What broke/changed? I think my upgrade to PHP 8 was after my last successful mailing. Or did anything change in recent Mautic upgrades that requires email config or cronjob changes?

Hi,
You need to test this:

  1. check how many emails are in the pool.
    This command counts the files:
    ls | wc

  2. If there are any try to run your mautic:emails:send command.
    Did it send out the emails?

  • If yes, then this command is configured wrong in your crontab. (probably not the case). Check for typos.
  • If no, then check error log.
    ā€“ Any related entries?
    ā€“ Do you get an error? For example some of the files cannot be read?
    ā€“ Do you see any files, with NOT .message extension?
  1. If there are no emails in your spool folder, then make a test send and start from step 1.
1 Like

Thank you @joeyk !

This is an error that shows up in logs when I try to force send via the command line:

ā€œrename(): supplied resource is not a valid Stream-Context resourceā€

Someone here mentions the same error. Iā€™ll look into this further laterā€¦

The initial sending attempt produces errors in logs similar to these - Error 503: Valid RCPT command must precede DATA - but Iā€™m confused if that applies to the recipient or my server. I have never had problems with SMTP authentication before and havenā€™t changed any settings.

Initial send attempt error in logs:

[2023-04-24 22:25:23] console.CRITICAL: Error thrown while running command ā€œmautic:emails:sendā€. Message: "Expected response code 354 but got code ā€œ503ā€, with message "503-All RCPT commands were rejected with this error: 503-The mail server could not deliver mail to jane.doe@recipient.co.uk. 503-The account or domain may not exist, they may be blacklisted, or missing 503-the proper dns entries. 503 Valid RCPT command must precede DATA " Log data: >> . << 250 OK id=1pr4cd-00043a-1E >> MAIL FROM:mod@mydomainname.com >> RCPT TO:another.recipient@website.org.uk >> DATA << 250 OK << 250 Accepted << 354 Enter message, ending with ā€œ.ā€ on a line by itself >> . << 250 OK id=1pr4cd-00043a-23 >> ā€¦ etc.

Sorry, no idea.

Working on this again this weekend, trying to restart my business from another stand-still. Sent out another mailing to a small test segment of other email addresses I own - gmail etc. Nothing arrives. No errors in logs.

Trying to force sending from command line with php bin/console mautic:emails:send gives this error:

In ProcessEmailQueueCommand.php line 141:

  rename(): supplied resource is not a valid Stream-Context resource

mautic:emails:send [--message-limit [MESSAGE-LIMIT]] [--time-limit [TIME-LIMIT]] [--do-not-clear] [--recover-timeout [RECOVER-TIMEOUT]] [--clear-timeout [CLEAR-TIMEOUT]] [--lock-name [LOCK-NAME]] [--bypass-locking] [-t|--timeout TIMEOUT] [-x|--lock_mode LOCK_MODE] [-f|--force] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

What is this rename() function? Where is it used in the process? How can I find out?

When I use ls | wc as suggested by @joeyk I get this as response:

26      26     309

What does that mean? If 26 or 309 is the number of emails in the pool/queue (?) that is way more than I would expect.

With php bin/console mautic:messages:send I get this response:

Processing message queue
Messages sent: 0

The rename() error is also mentioned here and here - will research there furtherā€¦

Line 141 in ProcessEmailQueueCommand.php is the following:

        //set spool message limit
        if ($msgLimit = $input->getOption('message-limit')) {
            $commandArgs['--message-limit'] = $msgLimit;
        } elseif ($msgLimit = $container->getParameter('mautic.mailer_spool_msg_limit')) {
            $commandArgs['--message-limit'] = $msgLimit;
        }


I donā€™t see rename() there, so where does that come in? What does ā€˜supplied resource is not a valid Stream-Context resourceā€™ mean? How does this work together?

I have not made any changes to message limits configuration btw; sending worked fine before with the same settings.

Hereā€™s another one with the same error message. Unfortunately @mindeswxā€™s solution there does not work for me; I have always had that ā€˜Use owner as mailerā€™ setting set to ā€˜Noā€™.

I guess to use ls | wc you have to change directory to the spool folder first? That is why I got unexpected results earlier I guess.

Where is the spool folder? Here according to Google:

You should find it in either /var/spool/mail/ (the traditional location) or /var/mail (new recommended location).

Could it be that the spool folder on my VPS was changed in an upgrade and that Mautic now canā€™t find the folder?

Result of ls | wc on /var/spool/mail/ is 0 0 0

Result of ls | wc on /var/mail/ is also 0 0 0

In both cases I would expect two emails that Mautic claims have been sent, but never arrived (in my test email boxes).

Mautic has its own spool dir., usually in /var/spool

If I would have to guess something interrupted the process and now some files are in invalid state.

Another option is that the spool folder/content has wrong owner (make sure is the same user as runs cronjob)

1 Like

Thanks @mzagmajster. There were a lot of .message files stuck (?) in that spool folder. I am deleting them now. How can files end up in an ā€˜invalid stateā€™? What does that mean?

If there were an ownership mismatch between cronjob and spool, I should still have been able to send out the emails with php bin/console mautic:emails:send, right? So I think I can eliminate that issue?

I found the cron jobs I set up years ago in /var/spool/cron. Two of them look like this:

*/3 * * * * /usr/local/bin/ea-php74 /home/myusername/public_html/mautic/bin/console mautic:emails:send >/dev/null 2>&1

I guess /ea-php74 could cause problems, since I have remove php7 and am on php8 now. Other lines have /usr/local/bin/php, so Iā€™ll change it to that.

I also saw this ā€œerrorā€ in the logs. I am trying to send from an email address that is an addon/alias of the main domain on my server - always worked fine in the past. Maybe there is a handover or certificate problem there somewhere. I have tried to clean that up on my server, whitelist my IP address as allowed sender, etc.

Like I said, something probably went wrong or the process got interrupted and as a result the script cannot pick up where it left of. From what you have provided its not possible to know how exactly it went wrong.

Not necessarily. It depends on which user on OS you use to send and how mautic permissions / ownership on the files is configured.

Mautic filesystem should be properly locked down and most of the files should only be readable from the webserverĀ“s point of view.

Cronjob should run by the same user that runs the webserver.

I would stop all the sending from mautic create a test segment with just you as a contact and try to first send one email (to yourself). When this works I would again try to send to real contacts.

1 Like

Thanks @mzagmajster. Having ea-php74 in the cron job caused the problems - I had upgraded to php8 and removed 7 since the last mailing. After replacing it with /usr/local/bin/php the test mailing went through.

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.