我实际上在laravel上与mailgun斗争,我在laravel 6上,我已经设置了auth并试图使密码重置功能起作用。因此,我决定将mailgun用作电子邮件服务器,
这是我的.env文件:
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
MAIL_USERNAME=postmaster@parisworld.ovh
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', 'support@parisworld.ovh'),
'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'),
]
还有我的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'),
],
];
我没有得到我真正缺少的东西,我配置了mailgun域并验证了dns,在mailgun方面一切正常,我什至可以使用curl方法向自己发送邮件,但是当我尝试重置我的邮件时我的应用输入密码时出现此错误:
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" }
我希望这篇文章足够清楚,欢迎任何想法:)
答案 0 :(得分:3)
.env文件
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
有关端点https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions
的更多信息答案 1 :(得分:1)
好了,我找到了解决此问题的方法,我在欧盟创建了我的帐户,默认情况下,当您引用mailgun api URL时,smtp.maigun.org对应于美国api。因此,laravel在欧盟注册时正在美国api中寻找parisworld.ovh域。 要使用mailgun的eu api,您必须在.env中进行更改(以我为例):
MAIL_HOST=smtp.mailgun.org
到
MAIL_HOST=smtp.eu.mailgun.org
我不知道为什么,但是我仍然遇到身份验证问题:
要解决此问题,我只需要从mailgun界面重置我的smtp密码,然后将新密码粘贴到我的.env中即可使用! 希望这篇文章对您有所帮助:)
答案 2 :(得分:1)
如果您在欧盟,则需要确保在config / services.php中设置以下内容
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'endpoint' => env('MAILGUN_ENDPOINT'),
'secret' => env('MAILGUN_SECRET'),
],
,然后将以下内容添加到您的.env
MAILGUN_ENDPOINT=api.eu.mailgun.net
然后
php artisan config:cache