Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Vijitha 8 posts 98 karma points
    May 30, 2022 @ 12:05
    Vijitha
    0

    Access SMtp globalsettings in Surfacecontroller

    How do I get smtp setting from the globalsettings in a surfacecontroller in umbraco v9 ?

  • Dennis 75 posts 398 karma points MVP 2x
    May 30, 2022 @ 13:57
    Dennis
    0

    If you look in the Umbraco source on GitHub, you can see that the GlobalSettings class has a property Smtp. You can read the settings from that object.

    In surface controllers you can use dependency injection, so you can simply add a constructor and pass the global settings in there like this:

    public class MyController : SurfaceController
    {
        public MyController(IOptions<GlobalSettings> globalSettings)
        { ... }
    }
    

    Kind regards,
    Dennis

  • AJ Murray 13 posts 122 karma points
    Sep 10, 2024 @ 05:37
    AJ  Murray
    0

    Just a bit more information about the answer that was mentioned, as it helped me a lot. The Umbraco documentation can be found here. Configuration

Please Sign in or register to post replies

Write your reply to:

Draft