Unable to send example email

Your software
My Mautic version is: 6.0.2
My PHP version is: 8.3
My Database type and version is: Ver 15.1 Distrib 10.3.39-MariaDB

Your problem
My problem is:
Sending example email does not work.

These errors are showing in the log:

[2025-06-10T21:19:51.281965+00:00] messenger.CRITICAL: Error thrown while handling message Symfony\Component\Mailer\Messenger\SendEmailMessage. Removing from transport after 3 retries. Error: "Handling "Symfony\Component\Mailer\Messenger\SendEmailMessage" failed: Connection could not be established with host "localhost:25": stream_socket_client(): Unable to connect to localhost:25 (Connection refused)" {"class":"Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage","retryCount":3,"error":"Handling \"Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage\" failed: Connection could not be established with host \"localhost:25\": stream_socket_client(): Unable to connect to localhost:25 (Connection refused)","exception":"[object] (Symfony\\Component\\Messenger\\Exception\\HandlerFailedException(code: 0): Handling \"Symfony\\Component\\Mailer\\Messenger\\SendEmailMessage\" failed: Connection could not be established with host \"localhost:25\": stream_socket_client(): Unable to connect to localhost:25 (Connection refused) at /srv/mautic/vendor/symfony/messenger/Middleware/HandleMessageMiddleware.php:124)\n[previous exception] [object] (Symfony\\Component\\Mailer\\Exception\\TransportException(code: 0): Connection could not be established with host \"localhost:25\": stream_socket_client(): Unable to connect to localhost:25 (Connection refused) at /srv/mautic/vendor/symfony/mailer/Transport/Smtp/Stream/SocketStream.php:154)"} {"hostname":"REDACTED","pid":26400}

Steps I have tried to fix the problem:
Cleared cache.
Verified email DSN: smtp://USERNAME:SECRET@smtp-broadcasts.postmarkapp.com:25
Sending test from the settings page works.

Seems others were having similar problem here (doesn’t look to be related to AWS btw): Cannot send emails to contacts with AWS SES plugin · Issue #14584 · mautic/mautic · GitHub

Seems that it is ignoring the DNS and trying to send from the default of localhost:25.

Hello,
Can you paste here an example DSN you are trying to use?
Just replace the user:secret for your securtiy.

The plugin you mention doesn’t actually send email, but manages feedback loops.
For sending via API you need to install:

composer require symfony/amazon-mailer

@joeyk The DSN is in my post. And I mentioned it has nothing to do with the AES mailer, which that GitHub issue also says in a comment, but the problem is same I am experiencing, any SMTP or DSN is being ignored when using the Send Example button.

Hello, sorry I missed the DSN :confused:
Do you have port 25 available on your server?
It’s mostly blocked - and you error also suggest that.

@joeyk That is the problem, it should not be attempting to use localhost:25 at all. That is the default SMTP for Symfony Mailer. But I have the DSN set to smtp-broadcasts.postmarkapp.com:25.

1 Like

I’m not sure if this is resolved now.
:25 means port 25

I’m not sure what you are saying. Nothing is resolved. The logs show that the mailer is trying to connect to localhost:25. But my DSN is set to smtp-broadcasts.postmarkapp.com:25, so localhost should not be involved with anything at all.

I just made a change to our queue service configuration file, adding full path to PHP executable, and it is now sending.

/etc/systemd/system/mautic-messenger-worker@.service I changed:

ExecStart=php8.3 /srv/mautic/bin/console messenger:consume email --memory-limit=1024M

to

ExecStart=/usr/bin/php8.3 /srv/mautic/bin/console messenger:consume email --memory-limit=1024M

And now emails are sending fine.

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