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

nanadjei2's avatar

Testing mailtrap.io on a server

I have just push a project to development and I want to test the mail with mailtrap.io API. The configuration works on my local machine but not on the shared host server.

I get this error... production.ERROR: Connection could not be established with host smtp.mailtrap.io [Connection refused #111] {"exception":"[object] (Swift_TransportException(code: 0): Connection could not be established with host smtp.mailtrap.io

This is my .env

     MAIL_DRIVER=smtp
     MAIL_HOST=smtp.mailtrap.io
     MAIL_PORT=2525
     MAIL_USERNAME=**************
     MAIL_PASSWORD=***************
     MAIL_ENCRYPTION=tls

Can any help me.

0 likes
14 replies
nanadjei2's avatar

Yes I have tried that and I get my success message but the email does not show in mailtrap.io

rin4ik's avatar

@nanadjei2 it should work. maybe you will try change port from 2525 to 465

MAIL_PORT=465
nanadjei2's avatar

Still the error persist. Getting my success message but mail not received in mailtrap.io

Snapey's avatar

Your shared server might have port restrictions?

if you have command line access you could try ping or telnet to see if you can reach their server

nanadjei2's avatar

Ohh I see based on this https://d.pr/free/i/Gihv3e you pasted. Mailtrap cannot be used in production. Then I don't have any problem with that once am getting my success message I can proceed is that right?

Snapey's avatar

Thats bogus

Mailtrap does not know if you are in production or not. Thats just telling you that it is not a mail relay service. Its designed for testing.

You say you want to test with mailtrap.io - that IS what it is for..

1 like
nanadjei2's avatar

@Snapey Am not using it as my actual mail service. I wanted to know if my nothing has broken and the mail still works as locally that is all what I wanted to do. But based on your comment that mean it should have still worked right? If yes then my problem is why am I not receiving the message. If No them I understand.

nanadjei2's avatar

Please do kindly assist me with the configuration of a shared host email with laravel.

Snapey's avatar

Its perhaps worth sharing the problem with the host provider. They may have seen it. They may know that they are blocking you from contacting other servers on certain ports

Please or to participate in this conversation.