I have been searching, I checked Laravel 5 documentation but I haven’t found anything. In the Laravel .env example file it shows how you can set it to send from one email address, but say I want to send from different email addresses for different situations, how would I do that?
There’s no de facto way to set multiple from addresses. How you implement this is up to you.
One approach would be to create a config file (say config/addresses.php) that has an array of your addresses:
return [
'enquiries' => 'someone@example.com',
'orders' => 'someone.else@example.com',
];
And then just select them when sending an email:
Mail::send('enquiry', $data, function ($message) {
$message->from(config('addresses.enquiries'));
});
If you don’t want email addresses hard-coded in your application’s source code like this, then you could either move them to environment variables, or the database if you want them configurable.