Support the ongoing development of Laravel.io →
posted 10 years ago
Mail
Last updated 2 years ago.
0

Ok I fixed this...

I had not set a default from address in config/mail.php. I want to be able to deploy my app to others, so am trying not to define config settings specific to me.

So then the example mail code in the Laravel docs says nothing of the necessity of setting a from address, so overlooked that (edit: actually it does, but further up in the intro and not in the example code, so if you're like me who speed through things learn from copying and pasting then I suppose it's asking for it!)

So basically needed to set a from address like so:

Mail::send('emails.welcome', array(), function($message)
{
    $message
    	->to('[email protected]')
    	->from('[email protected]')
    	->subject('TEST');
});

Thats copying and pasting for you and not really thinking about how it works.

Last updated 2 years ago.
0

What you may be able to do is use Laravel's environment detection to load one set of configs for local development and to use your normal config files for any other.

You can read more on that here: http://laravel.com/docs/configuration#environment-configuration

Last updated 2 years ago.
0

If you have multi-tenant application where you take from address from database, you can

  • Set a default from in app/config/mail.php
  • Change the config on run-time :
Config::set('mail.from.address', $model->email);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

amityweb amityweb Joined 8 Feb 2014

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.

© 2024 Laravel.io - All rights reserved.