More in this section
Forums / Developing with Sitefinity / getting smtp settings

getting smtp settings

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
7 posts, 0 answered
  1. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    12 Oct 2012
    01 Mar 2013
    Link to this post


    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?

  2. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    18 Feb 2004
    01 Mar 2013 in reply to Amanda Shafer
    Link to this post

    Hi Amanda,

    To use the default profile from the Notification service, you could use e.g. this code:

    var senderProfileName = "Default";
    var context = new ServiceContext("myNotificationAccount", "MyCustomModule");
    INotificationService ns = SystemManager.GetNotificationService();
    ISenderProfile profile = ns.GetSenderProfile(context, senderProfileName);
    if (profile.ProfileType == "smtp") {
       // Read the properties out of the CustomProperties property
       // [0]: {[useSSL, False]}
       // [1]: {[defaultSenderEmailAddress, ]}
       // [2]: {[password, ]}
       // [3]: {[username, ]}
       // [4]: {[host, ]}
       // [5]: {[port, 25]}
       // [6]: {[useAuthentication, False]}

    Not sure if that is the best way of doing this, but for me that worked.

    Kind regards,

  3. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    12 Oct 2012
    01 Mar 2013 in reply to Daniel Plomp
    Link to this post

    That worked. Thanks so much Daniel!

  4. Chanan Zass
    Chanan Zass avatar
    123 posts
    21 Aug 2012
    17 Mar 2013 in reply to Amanda Shafer
    Link to this post
    Imports Telerik.Sitefinity.Configuration.Config
    Imports Telerik.Sitefinity.Configuration
    Imports Telerik.Sitefinity.Services.Notifications.Configuration

    Dim manager As ConfigManager = ConfigManager.GetManager()
    Dim section As NotificationsConfig = manager.GetSection(Of NotificationsConfig)()
    Dim myProfile As SmtpSenderProfileElement = section.Profiles("Default")

    Dim myhost As String = myProfile.Host.ToString
  5. Martin Scheer
    Martin Scheer avatar
    1 posts
    19 Mar 2012
    04 Oct 2013
    Link to this post

    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: 

    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Services;

    var smtpSettings = Config.Get<SystemConfig>().SmtpSettings;

    This is in no way related to the Notification system's profiles, however someone that stumbles on this thread may find it useful. :) 
  6. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    31 May 2017
    07 Oct 2013
    Link to this post

    Thank you for sharing this information with the community.

    Stefani Tacheva
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Jacques
    Jacques avatar
    427 posts
    28 Jun 2007
    27 Sep 2017 in reply to Daniel Plomp
    Link to this post

    Hi Daniel, 

    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? 

7 posts, 0 answered