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 397 karma points MVP
    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

Please Sign in or register to post replies

Write your reply to:

Draft