Support the ongoing development of Laravel.io →
Configuration Mail

Hey there,

Ive got an application in which the models can sent emails when they have some specific changes. Only now the client wants an import script and in the cron job the models are triggerd to send an email.

How do i set the config of mail to pretend in the code during runtime?

ive tried the following, but no effect

// save current config state
$oldconfig = Config::get('mail.pretend');
// set config to pretend 
$config::set('mail.pretend', true);

/* import code goes here */

// reset config to previous state
Config::set('mail.pretend', $oldconfig);

if someone has a answer i'd be very grateful!

Thanks a bunch

Last updated 2 years ago.
0
// set config to pretend 
$config::set('mail.pretend', true);

Should be

// set config to pretend 
Config::set('mail.pretend', true);

I don't think thats the right way though. Can't you just pass a flag with the event, that tells your mailer script/class not to send an email?

Last updated 2 years ago.
0

Herlevsen said:

// set config to pretend $config::set('mail.pretend', true);

Should be

// set config to pretend Config::set('mail.pretend', true);

I don't think thats the right way though. Can't you just pass a flag with the event, that tells your mailer script/class not to send an email?

Sure, but i expect a great framework like L4 to have a solution that is more robust. In my case i mail through 1 point, so no problem. But what if you are a crappy programmer and the application mails in like 20 places?

So this is not in L4? To bad :'(

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.