Copied to clipboard

Flag this post as spam?

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


  • mukund rayate 22 posts 172 karma points
    Jun 13, 2016 @ 07:11
    mukund rayate
    0

    Can We send mail without setting username and password in web.config ?

    I am trying to send mail , but i don't want to set my user name and password in web.config ? My be set some where else so i can assess securely. can you guide me on this ?

  • Paulius Putna 78 posts 136 karma points
    Jun 13, 2016 @ 08:01
    Paulius Putna
    0

    Hi,

    You can set in the web.config file:

    <system.net>
      <mailSettings>
       <smtp configSource="MailSettings.config"/>
      </mailSettings>
    </system.net>
    

    And have all your login details in the external file:

       <network 
        host="relayServerHostname" 
        port="portNumber"
        userName="username"
        password="password" />
    

    Probably worth putting the MailSettings.config in the Config folder.

  • mukund rayate 22 posts 172 karma points
    Jun 21, 2016 @ 13:00
    mukund rayate
    100

    I removing user name and password from mail setting and use it directly in my code .

  • Paulius Putna 78 posts 136 karma points
    Jun 21, 2016 @ 13:10
    Paulius Putna
    0

    Then you would have to repeat login details each time.

    Using a .config file make them global across all of your code.

    Both work.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies