Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rretzko's avatar
Level 15

Can't get smtp working with Postmarkapp

I'm trying to set up transactional emails through Postmark, but hitting the following error:

Connection could not be established with host smtp.postmarkapp.com :stream_socket_client(): unable to connect to smtp.postmarkapp.com:587 (Connection refused) {"exception":"[object] (Swift_TransportException(code: 0): Connection could not be established with host smtp.postmarkapp.com :stream_socket_client(): unable to connect to smtp.postmarkapp.com:587 (Connection refused) at /home/ds8x2d76z4exc9ht/public_html/thedirectorsroom.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:269)

My config\mail.php settings are:

'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.postmarkapp.com'),
            'port' => env('MAIL_PORT', 587),
            'encryption' => env('MAIL_ENCRYPTION', 'tls'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'auth_mode' => null,
        ],

My .env settings are:

MAIL_MAILER=smtp
MAIL_HOST=smtp.postmarkapp.com

MAIL_DRIVER=postmark
MAIL_USERNAME=ccccc18c-56cc-484f-adcd-12cc2ccc2999
MAIL_PASSWORD=ccccc18c-56cc-484f-adcd-12cc2ccc2999
MAIL_ENCRYPTION=NULL
[email protected]
MAIL_FROM_NAME="Rick Retzko"
POSTMARK_SECRET=ccccccc15c-55cc-484c-cccc-11cc9ccc1111

I had transactional emails previously set up on Mandrill, but am trying to switch to Postmark. I'm hosted on GoDaddy if that makes any difference. Any and all assistance is appreciated, Thanks!

0 likes
8 replies
Rretzko's avatar
Level 15

Thanks @snapey ! I tried that (changing mail_driver from postmark to smtp) but that didn't change the behavior or error message. Postmark Support got back to me with: "Are you able to tell me a little bit more about how you're sending messages with Laravel to Postmark? Are you using PHPMailer for SMTP sending? Based on the error that you received, it looks like you're using TLSv1.0 to connect, we require TLSv1.1+." I've replied that I'm using vanilla Laravel Swiftmailer and not sure where TLS is configured. If this is in the product, I'm using Laravel 8, so I'd expect it be pulling the right version. Let me know if you have any other advice!

Snapey's avatar

thats strange because your config is null for TLS

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

and .env

MAIL_ENCRYPTION=NULL

have you cleared config cache?

btw. I use postmark and use TLS=null

Rretzko's avatar
Level 15

Hi again - Maybe some progress here. I changed to MAIL_ENCRYPTION=TLS and re-ran the app. It looks like I may have cleared the first problem and I’m now getting the following error:

[2021-06-09 19:08:54] prod.ERROR: Class 'Postmark\Transport' not found {"exception":"[object] (Error(code: 0): Class 'Postmark\Transport' not found at /home/ds66z4exc9ht/public_html/thedirectorsroom.com/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php:330)
[stacktrace]

I have "coconutcraig/laravel-postmark": "^2.10" in my composer.json, but do not find a vendors/Postmark directory. Thoughts?

Snapey's avatar

you are using smtp not the postmark api ? Aren't you?

Rretzko's avatar
Level 15

Yup: .env MAIL_MAILER=postmark MAIL_HOST=smtp.postmarkapp.com

Rretzko's avatar
Rretzko
OP
Best Answer
Level 15

Hi @snapey - Thanks for your help and suggestions! I’ve worked through the issues and am now processing emails through Postmark. The nut of the case seems to have been an inability on my production server to load coconutcraig/Laravel-postmark. My ISP (GoDaddy) provided no assistance other than to suggest that the vendor's software couldn’t be loaded on their server. GoDaddy's first-level support has gotten worse by the year and they dropped the line when trying to transfer me to their second-line support. I ended up downloading the production system to my local dev environment, loading coconutcraig/Laravel-postmark, tweaking the configs until I got it working and then uploading the new vendor files to the production server. A couple of refreshes later, it is working as expected. One point to note in case this can help someone else: The MAIL_ENCRYPTION setting on the .env file needed to be null, not TLS. Thanks for working on this with me.

Snapey's avatar

glad you got it working, but note that I frequently use postmark and have never used anything other than the built in smtp driver

The api route might be quicker but it's never an issue

Please or to participate in this conversation.