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

agilasadi's avatar

I'm trying to send mails when a user signs up. and getting connection error.

I use event listener for that and to try my mailing I use mailtrap, but I get an error that I don't know what excacly cousing it. here is what it looks like:

Connection could not be established with host smtp.mailtrap.io [php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. #0]

Btw I defined all the infromation required in .env file

0 likes
3 replies
Cronix's avatar

What happens if you ping smtp.mailtrap.io from the cli on that box? Does it resolve to an IP? That error (php_network_getaddresses: getaddrinfo failed) is usually caused by DNS issues on the server and not necessarily your code.

Also, this is what you have in your .env?

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=mailtrap-username
MAIL_PASSWORD=mailtrap-password
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=from-address
MAIL_FROM_NAME="From Name"
agilasadi's avatar

Yeah that is what I have in my .env but when I ping smtp.mailtrap.io the request times out

Cronix's avatar

You'll have to fix the DNS on your server then. Not sure how to help with that beyond googling php_network_getaddresses: getaddrinfo failed and your servers os.

Please or to participate in this conversation.