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

Rykono's avatar

Curl Error 6 Could not resolve host: https Mailgun

Laravel 5.7.19

When trying to send an email via Mailgun using the Mail/Mailable class I get a curl error 6 Could not resolve host: https

This is on a windows environment but i can send request normally on the command line using curl. With no problems which leads me to beleive this is a laravel config problem.

I also have some other normal guzzlehttp functions in my app that are sending requests normally.

If i send to 'endpoint' 'api.mailgun.net/v3/sandboxd**********************d.mailgun.org/messages'

I get no return or error from the command.  Mail::failures() returns an empty array. Mailgun shows no new outgoing email.
If i send to 'endpoint' 'https://api.mailgun.net/v3/sandboxd**********************d.mailgun.org/messages'

I get the cannot resolve host : https
If i send to 'endpoint' 'http://api.mailgun.net/v3/sandboxd**********************d.mailgun.org/messages'

I get the cannot resolve host : http

It looks like laravel is not giving the entire url to mail sender.

I have tried setting Mailgun credentials in both the ENV and the services.php.

I have tried using quotes and without quotes in the ENV

What am i missing here?

0 likes
2 replies
Rykono's avatar
Rykono
OP
Best Answer
Level 1

'endpoint' is not needed.... in .env or services.

1 like
codercrew's avatar

Hello! Endpoint is needed when you are sending from Mailgun's EU infrastructure. So in .env file you need this line:

MAILGUN_ENDPOINT=api.eu.mailgun.net

So without http or https and without the request path ("/v3/sandbox..."). Laravel uses this env var like this: "https://{$this->endpoint}/v3/{$this->domain}/messages.mime"

Please or to participate in this conversation.