Laravel 5.5 mailgun does not send emails - no errors

I am trying to send emails with mailgun, but they are not sent, and I have no idea why, because I am not getting any errors at all.

This is my code:

mail.php:

'driver' => env('MAIL_DRIVER', 'mailgun'),

services.php:

'mailgun' => [
    'domain' => env('sandbox1e...60.mailgun.org'),
    'secret' => env('key-146...419'),
],

EmailController.php:

public function send($email, $uuid = null)
{
    if($uuid == null){
        $uuid = User::get()->where('customer_email' , $email)->first()->email_confirmed;
    }

    return Mail::to($email)->send(new ConfirmEmail($uuid));

}

ConfirmEmail.php:

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class ConfirmEmail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public $uuid;

    public function __construct($uuid)
    {
        $this->uuid = $uuid;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->from('mailgun@sandbox1e17506823f2490ba9cc78cbbc2adb60.mailgun.org')
            ->view('emails.confirm');
    }
}

I added the email address I want to send to mailgun, but it does not work. Am I doing something wrong or can I debug this?

+4
source share
1 answer

Your configuration is incorrect:

'mailgun' => [
    'domain' => env('sandbox1e...60.mailgun.org'),
    'secret' => env('key-146...419'),
],

The env function searches for an environment variable with the name you specify and returns a value. You must change it to the name of the environment variable and define it in your .env or not use the env function.

+5
source

Source: https://habr.com/ru/post/1692324/


All Articles