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

ApexLeo's avatar

Laravel mail to mailtrap from sharedhosting.

Hello everyone, i am having an issue sending mail from laravel to mailtrap.

for your info.

  1. i have run my mailtrap configurations on local it work fine.
  2. i have run my gmail configurations on shared hosting they work fine as well.
  3. when i run my mailtrap configurations on shared hosting here come the issue.

Error Screenshot on shared hosting

Screenshot Link

Mailtrap config (work fine on local, but issue on server)

 
MAIL_MAILER=smtp // i have also tried snedmail, mailgun etc.
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=**************
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@**************
MAIL_FROM_NAME="${APP_NAME}"

Gmail Config (work fine on server)


MAIL_MAILER=sendmail
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=noreply@************
MAIL_PASSWORD=************
MAIL_FROM_ADDRESS=noreply@************
MAIL_FROM_NAME="${APP_NAME}"
0 likes
7 replies
Sinnbeck's avatar

Try another port. Give 587 a go (instead of 2525)

Otherwise, just contact your hosting provider and ask if you are allowed to send via smtp, and if so, on what port. They should know that.

ApexLeo's avatar

@sinnbeck hello sinnbeck thnaks for your time i also tried 25 or 465 or 587 or 2525 none of them work and all give the same error with or without tls encription

i will try contacting them

Snapey's avatar

make sure you wrap your password in quotes

Sinnbeck's avatar

How about (changed mailer, port and encryption)

MAIL_MAILER=sendmail
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=465
MAIL_USERNAME=**************
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@**************
MAIL_FROM_NAME="${APP_NAME}"
ApexLeo's avatar

@snapey my passowrd didn't contain # or any space but for safe side i did that as u mentioned but result is same.

@sinnbeck i also try sendmail, mailgun, smtp but none of them work and as u mentioned earlier i did contact my hosting provider they say they allow SMTP on their server with PORTS 25, 465, 587 and 2525. but none of the ports work

ApexLeo's avatar

@sinnbeck @snapey here is something that i found

i have an email [email protected]

when i send email to [email protected] using mailtrap config but with mailer "sendmail" it send mail to [email protected] instead of mailtrap account

here is config


MAIL_MAILER=sendmail
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=**************
MAIL_PASSWORD=**************
MAIL_ENCRYPTION=tsl
MAIL_FROM_ADDRESS=noreply@**************
MAIL_FROM_NAME="${APP_NAME}"

even though this has nothing to do with my issue this is just for information

Snapey's avatar

when checking your config, use tinker. This will give you a true picture of the current config

php artisan tinker

>>> config('mail')
1 like

Please or to participate in this conversation.