Reputation: 55
I would like to use multiple sender's email (smtp) for different cases with actionmailer MVC
.
For example, if it's a new user registering, then the confirmation will be sent with the [email protected]
email.
If the user get contact by another user, the sender email will be [email protected]
.
So I need to setup 3-4 smtp, and use them in actionmailer. So far, webconfig
can't support multiple smtp. Thks
Upvotes: 0
Views: 1575
Reputation: 16595
MailerBase
has a property From
available (among others) that you can set in C# depending on whatever logic you use. Then combine that with <appSettings>
from the web.config you can do something like:
<appSettings>
<add key="RegistrationFromAddress" value="[email protected]" />
<add key="ContactFromAddress" value="[email protected]" />
</appSettings>
then in your controller
public class MailController : MailerBase
{
public EmailResult RegisterEmail()
{
From = System.Configuration.ConfigurationManager.AppSettings["RegistrationFrom"]; // or ContactFromAddress if you want
}
}
Upvotes: 1