duanqiang6501 2017-04-18 13:11
浏览 46
已采纳

Laravel和Mailgun无法正常工作

Before production version I used mailtrap to test my emails and everything worked like it should be, but today I uploaded my website to a public server and decided to use mailgun, I know its not so simple like mailtrap.io, but still. Anyway I verified my account and can now send 10k emails per month. Not bad, but the thing is when I try to send an email I get a notification that the email was sent, but there is no email in any inbox.

My .env file

MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=myEmail
MAIL_PASSWORD=myPassword
MAIL_ENCRYPTION=tls

My services.php file

return [

'mailgun' => [
    'domain' => env('myDomain'),
    'secret' => env('secretKey'),
],

'ses' => [
    'key' => env('SES_KEY'),
    'secret' => env('SES_SECRET'),
    'region' => 'us-east-1',
],

'sparkpost' => [
    'secret' => env('SPARKPOST_SECRET'),
],

'stripe' => [
    'model' => App\User::class,
    'key' => env('STRIPE_KEY'),
    'secret' => env('STRIPE_SECRET'),
],

];

One of the functions:

public function store(StoreListingContactFormRequest $request, Area $area, Listing $listing){

        Mail::to($listing->user)->queue(
            new ListingContactCreated($listing,
                $request->name,
                $request->email,
                $request->number,
                $request->message
            )
        );
        return back()->withSuccess("Teie sõnum on edukalt saadetud firmale {$listing->user->name}");
    }

Another one:

public function __construct()
    {
        $this->middleware(['auth']);
    }

    public function index(Area $area, Listing $listing){
        return view('listings.share.index', compact('listing'));
    }

    public function store(StoreListingShareFormRequest $request, Area $area, Listing $listing){

        collect(array_filter($request->emails))->each(function($email) use ($listing, $request){
            Mail::to($email)->queue(
                new ListingShared($listing, $request->user(), $request->messages)
            );
        });

        return redirect()->route('listings.show',[$area, $listing])->withSuccess('Kuulutus on jagatud edukalt!');
    }
  • 写回答

1条回答 默认 最新

  • dongzhuange2625 2017-05-05 10:57
    关注

    seems the error is here

    MAIL_USERNAME=myEmail

    MAIL_PASSWORD=myPassword

    MAIL_USERNAME should be not your email but Default SMTP Login from your domain settings page. And Default Password on the same page for MAIL_PASSWORD

    'domain' => env('myDomain'),

    here you need to enter not your site's domain but the domain you've registered on mailgun, something like mg.exmaple.com

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料