2

When I send it doesn't give me any errors, but I don't receive any email neither. I fixed all the DNS records and it has the green checkmarks by Mailgun

my .env looks like this:

MAIL_MAILER=mailgun
MAIL_HOST=smtp.eu.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=[postmaster username from mailgun]
MAIL_PASSWORD=[smtp password from mailgun]
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS[postmaster email]
MAIL_FROM_NAME=Webpage

I fixed the config.services like the Laravel documentation says

'mailgun' => [
    'domain' => 'your-mailgun-domain',
    'secret' => 'your-mailgun-key',
    'endpoint' => 'api.eu.mailgun.net',
],

and did

composer require guzzlehttp/guzzle

in my App\Mail folder I have Discount.php

class Discount extends Mailable
{
    use Queueable, SerializesModels;

    public $request;
    public $discount;

    public function __construct($request, $discount)
    {
        $this->request = $request;
        $this->discount = $discount;
    }

    public function build()
    {
        return $this->markdown('emails.discount')
            ->replyTo($this->request['email']);

    }
}

and lastly, in my controller I have

   public function find ()
    {
        [ ... ]

        Mail::to('myemail@mywebsite.com')->send(new Discount($request, $discount));

        return redirect()->back()->with('success', true);
    }

Every time I send it hits the return with 'success' but I get no email

Tbsw
  • 23
  • 2
  • Have you checked your Mailgun logs to see if Mailgun received your request? If it reaches, then it's not an issue related to your application, but other issues. – sykez Jul 29 '20 at 16:19
  • MG only stores correct states to not existing mailboxes, if an MX record is set, so that non delivery emails are sent back to the MG server. I had to set up a subdomain an add a MX record to the subdomain. This detailed description may help you: https://stackoverflow.com/questions/68150905/can-i-send-email-with-mailgun-sandbox-domain-under-my-local-os/68542876#68542876 – FredyWenger Jul 27 '21 at 11:09

0 Answers0