Before 5.0, I used to get my stmp settings using the following code:
var manager = ConfigManager.GetManager();
string smtpHost = manager.GetSection<NewslettersConfig>().SmtpHost;
int smtpPort = manager.GetSection<NewslettersConfig>().SmtpPort;
var smtpClient = new SmtpClient(smtpHost, smtpPort);
It still works, but I want to pull from the default profile for the notifications config instead. Can you please tell me how to do that?
To use the default profile from the Notification service, you could use e.g. this code:
var senderProfileName =
var context =
INotificationService ns = SystemManager.GetNotificationService();
ISenderProfile profile = ns.GetSenderProfile(context, senderProfileName);
// Read the properties out of the CustomProperties property
// : [useSSL, False]
// : [defaultSenderEmailAddress, ]
// : [password, ]
// : [username, ]
// : [host, ]
// : [port, 25]
// : [useAuthentication, False]
Not sure if that is the best way of doing this, but for me that worked.
That worked. Thanks so much Daniel!
I was searching for a reference earlier and this thread shows up first on google, here is a clean way of getting the system's smtp settings:
var smtpSettings = Config.Get<
I know this is an old post but I'm realising for the first time that Settings > System > SMTP is for pre SF 5x related features where as notification services is for post so I need to figure out how to use it correctly.
What's the purpose of "myNotificationAccount" and "MyCustomModule" parameters in ServiceContext? I'm seeing those same values in Sitefinity's documentation as well, but there's no explanation as to what they're for.
This service also seems related to a subscriber list so from a developers standpoint is this not overkill in terms of just wanting to send some error details through to someone?