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

ekpono's avatar
Level 12

Have switch to mailgun

λ nmap -Pn -pT:25 smtp.mailgun.org
Starting Nmap 7.70 ( https://nmap.org ) at 2018-10-11 23:42 W. Central Africa Standard Time
Stats: 0:00:06 elapsed; 0 hosts completed (0 up), 0 undergoing Host Discovery
Parallel DNS resolution of 1 host. Timing: About 0.00% done
Nmap scan report for smtp.mailgun.org (35.161.201.187)
Host is up (0.45s latency).
Other addresses for smtp.mailgun.org (not scanned): 52.26.154.214
rDNS record for 35.161.201.187: ec2-35-161-201-187.us-west-2.compute.amazonaws.com

PORT   STATE SERVICE
25/tcp open  smtp

Nmap done: 1 IP address (1 host up) scanned in 8.14 seconds

ekpono's avatar
Level 12
[koboitlz@server239 public_html]$ server
-bash: server: command not found

D9705996's avatar

To setup mailgun integration you need to run the following via ssh on your server in the folder where you installed your application.

composer require guzzlehttp/guzzle

Then modify .env to add these keys with your details from your mailgun account settings

MAILGUN_SECRET=
MAILGUN_DOMAIN=

Delete all the SMTP_...settings from .env and changeMAIL_DRIVER= from smtp to mailgun

Now try sending an email in you application.

ekpono's avatar
Level 12

Though the mailgun account is not verified Am still getting this when verifying

An error occurred while attempting to send your verification code, please try again. Contact Support if the issue persists.
Cronix's avatar

Did you contact mailgun support?

Cronix's avatar

I haven't used them. Is this verification code supposed to be sent via text message, email or what's it talking about?

ekpono's avatar
Level 12

yes .. it supposed to be sent via phone. But am not getting the code.

ekpono's avatar
Level 12

I talked to namecheap support, they gave me working port. @Cronix @D9705996 Thanks so much guyz. With selfless people like you guyz, i can build anything. It makes me want to give more to the community

2 likes
Nihir's avatar

Hi, I use Mailtrap for testing and the i got the same issue in my live server is there any solution for it?

achur00's avatar

@Nihir try changing "MAIL_MAILER=smtp" to " MAIL_MAILER=sendmail" on the live server.

Nihir's avatar

@achur00 I already tried it, but it has not worked in my case. Even when I search for the error on google, it seems like the problem was in the server means the blog says it does not work because of the cpanel firewall.

achur00's avatar

@Nihir you looked at your error log yet? try looking their maybe you can see something on that, just to be sure

MinaZakaria's avatar

@Nihir I faced the same issue, Try change MAIL_PORT between (25 or 465 or 587 or 2525)

achur00's avatar

@nihir Have you checked your mail.php. I had similar problem some times ago, and I fix it by using this in my env on local server :

 MAIL_MAILER=smtp
 MAIL_HOST=smtp.mailtrap.io
 MAIL_PORT=2525
 MAIL_USERNAME=example@mailtrap
 MAIL_PASSWORD=#####
 MAIL_ENCRYPTION=tls
 [email protected]
 MAIL_FROM_NAME="${APP_NAME}"
 //and on mail.php in config use: 'default' => env('MAIL_MAILER', 'smtp'),

// on the remote , the setting is pretty much the same :
 MAIL_DRIVER=sendmail
 MAIL_HOST=smtp.mailtrap.io
 MAIL_PORT=2525
 MAIL_USERNAME=example@mailtrap
 MAIL_PASSWORD=***********
 MAIL_ENCRYPTION=tls
 [email protected]
 MAIL_FROM_NAME="${APP_NAME}" 

 //and on mail.php in config use: 'default' => env('MAIL_MAILER', 'sendmail'),
Previous

Please or to participate in this conversation.