Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

404 not found mailgun domain on laravel

i'm actually struggling with mailgun's on laravel, I'm on laravel 6, i've set up auth and am trying to make the password reset functionnality work. So i decided to use mailgun as email server,

here is my .env file :

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:************
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=******
DB_USERNAME=******
DB_PASSWORD=******

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

mail.php:

<?php

return [
   'driver' => env('MAIL_DRIVER', 'mailgun'),
   'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
   'port' => env('MAIL_PORT', 587),
   'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Parisworld support'),
    ],
   'encryption' => env('MAIL_ENCRYPTION', 'tls'),
   'username' => env('MAIL_USERNAME'),
   'password' => env('MAIL_PASSWORD'),
   'sendmail' => '/usr/sbin/sendmail -bs',
   'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
   'log_channel' => env('MAIL_LOG_CHANNEL'),
]

And my services.php:

<?php

   return [
    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN', 'parisworld.ovh'),
        'secret' => env('MAILGUN_SECRET', '********'),
    ],

    'postmark' => [
        'token' => env('POSTMARK_TOKEN'),
    ],

    'ses' => [
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],

];

I don't get what I'm actually missing, i configured the mailgun domain and verified the dns, everything is fine on mailgun side, I could even send myself a mail using the curl method but when I try to reset my password from my app I'm getting this error :

Client error: `POST https://api.mailgun.net/v3/parisworld.ovh/messages.mime` resulted in a `404 NOT FOUND` response: { "message": "Domain not found: parisworld.ovh" } 

I hope this post is clear enought, any idea is welcome :)

like image 782
Nicolas Avatar asked Sep 30 '19 18:09

Nicolas


People also ask

How do I enable Domain in Mailgun?

Configure your Domain for Email In Mailgun, navigate to Sending > Domains click Add New Domain. Add your domain and follow the setup. You will be given two TXT (SPF and DKIM), two MX, and a CNAME record. Update these records in your DNS provider.

How many Domains can I have on Mailgun?

You can create custom domains. Use of Authorized Recipients is not required to send with custom domains; you may send to whomever you like! You can add up to 5 routes.

What is API Mailgun net?

The Mailgun API is built on HTTP. Our API is RESTful and it: Uses predictable, resource-oriented URLs. Uses built-in HTTP capabilities for passing parameters and authentication. Responds with standard HTTP response codes to indicate errors.


1 Answers

  1. On Mailgun Domains page (ex. https://app.eu.mailgun.com/app/sending/domains) get your domain region;
  2. Check Domain Settings -> DNS records;
  3. Edit .env-file:

.env file

MAIL_DRIVER=mailgun
MAILGUN_DOMAIN=mg.docm****.***
MAILGUN_SECRET=d76da6b39e********

# For EU Mailgun domain region
MAILGUN_ENDPOINT=api.eu.mailgun.net

# For US Mailgun domain region
MAILGUN_ENDPOINT=api.mailgun.net

More information about endpoints https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions

Mailgun: Domains page

Mailgun: Domain Settings -> DNS records

Mailgun: Domain Settings -> DNS records 2

like image 121
eFee Avatar answered Sep 23 '22 23:09

eFee