GMail + C# + Web.Config: Send Mail Works Programmatically, Throws Exception Using Web.Config Values

后端 未结 6 540
执笔经年
执笔经年 2020-12-14 19:16

Given the following section in Web.Config:


    
        

        
6条回答
  •  我在风中等你
    2020-12-14 19:33

    this is a configuration that worked perfectly for me:

    
        
          
            
          
        
      
    

    there is no way to add the SSL parameter to the network tag. You will have to set it from code:

    var smtpClient = new SmtpClient();
    smtpClient.EnableSsl = true;
    smtpClient.Send(message);
    

    If you don't want to send the emails out using an external smtp, you can configure it to use the localhost and use a desktop email receiver like PaperCut (http://papercut.codeplex.com/). This is the config to achieve that:

    
        
          
            
          
        
      
    

    Hope this helps!

提交回复
热议问题