Separate SMTP e-mail for each in Mutli-Company

Good day,
I’ve setup 2 companies (each have their own accounts@ mailbox).
In Invoice Ninja v5, however, in the .env file we only have the option to use one “MAIL_FROM_ADDRESS”

Is there a way for each company in a Multi-company setup to use their own mailbox settings?
Thanks in advance.

Hi,

I don’t believe this is supported yet.

cc @david in case I’m wrong…

Hi,

Same problem here. If you want a temporary/hacky workaround until the devs add this functionality, and you have the same mail server hosting the different domains, the following has worked for us:

I’ve changed the following line of code in app/Mail/TemplateEmail.php:

(Line 81)
From:
$this->from(config(‘mail.from.address’), $this->company->present()->name());

To:
$this->from($settings->reply_to_email,$settings->reply_to_name);

This sends our invoices from the reply-to email and reply-to name under Settings > Email Settings.

Again, only works because our SMTP credentials (username and password) are the same for the different domains we use. Also only tested on sending invoices - there may be other references in other files for different emails the system sends out.

1 Like

Thank you so much! Will give that a go :slight_smile:

Just to update, this is now supporter as per this thread

2 Likes

I was unable to get this to work. It seems to only use “MAIL_USERNAME=” when I removed it and used “1_MAIL_USERNAME=” it just defaulted to hello@example.com

What am I missing?

php artisan config:cache 
php artisan config:clear

Can you confirm you have ran this command?

Also, are you definitely seeing a problem with the MAIL_USERNAME field? or the MAIL_FROM_ADDRESS field?

Yea, sorry I meant the MAIL_FROM_ADDRESS field.

I ran both commands in succession but it doesn’t seem to work for me.

In the next release, we’ll also support the FROM_ADDRESS and FROM_NAME env variables to be per company also.

I upgraded to 5.5.40
I also manually deleted to config cache file from /bootstrap/cache

It is working as it should now, Thanks!

2 Likes