Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Laravel Emails - BeautyMail

Tags:

php

email

laravel

I'm looking for a way to disable sending of ALL emails from within Laravel. I'm working with a local deveopment copy of a website, and it's been sending off emails to actual users which is the last thing I want during testing.

What I've done:

I went into config/mail.php and added the following line:

    'pretend' => true,

Additionally, there was some configuration in the .env file related to Mailgun (a domain and secret) which I've removed, so that there should be no possibility of connecting to Mailgun.

After this, the system continues to send out emails during testing. My understanding was that setting 'pretend' to true should be enough to route all email sending to the log file.

It's worth noting that the system is using BeautyMail, which to my understanding is just an email templating system. It does, however, look like the email that keeps going out is sent using the BeautyMail send() function:

$beautymail = app()->make(\Snowfire\Beautymail\Beautymail::class);
    $beautymail->send('emails.templates.testemail', compact('url'), function ($message) use ($email) {
        $message->from(Mailer::$sender)->to($email)->subject('Test email');
    });

How can I disable this, and be sure that the system will not continue to fire off emails to actual users from my development environment?

like image 568
carbide20 Avatar asked Jul 19 '17 00:07

carbide20


People also ask

What are some good email templates for Laravel 4?

Beautymail makes it super easy to send beautiful responsive HTML emails. It's made for things like: If you're on Laravel 4, use the 1.x branch. There are tons of great looking HTML email templates out there.

How do I send email in Laravel?

Laravel and Symfony Mailer provide drivers for sending email via SMTP, Mailgun, Postmark, Amazon SES, and sendmail, allowing you to quickly get started sending mail through a local or cloud based service of your choice. Laravel's email services may be configured via your application's config/mail.php configuration file.

How do I create a mailable email in Laravel using Markdown?

Since the messages are written in Markdown, Laravel is able to render beautiful, responsive HTML templates for the messages while also automatically generating a plain-text counterpart. To generate a mailable with a corresponding Markdown template, you may use the --markdown option of the make:mail Artisan command:

What is the default Mailer configuration in Laravel?

Within your mail configuration file, you will find a mailers configuration array. This array contains a sample configuration entry for each of the major mail drivers / transports supported by Laravel, while the default configuration value determines which mailer will be used by default when your application needs to send an email message.


1 Answers

did you try to set 'driver' => env('MAIL_DRIVER', 'log'), in your config/mail.php or MAIL_DRIVER = log in .env

like image 77
CalidNofal Avatar answered Oct 07 '22 15:10

CalidNofal