C# MVCMailer smtp邮件设置以编程方式设置配置设置
MVCMailer使用web.config文件中的smtp设置,如下所示:C# MVCMailer smtp邮件设置以编程方式设置配置设置,c#,asp.net,asp.net-mvc-3,smtpclient,mvcmailer,C#,Asp.net,Asp.net Mvc 3,Smtpclient,Mvcmailer,MVCMailer使用web.config文件中的smtp设置,如下所示: <system.net> <mailSettings> <smtp from="some-email@gmail.com"> <network enableSsl="true" host="smtp.gmail.com" port="587" userName="some-email@gmail.com" password="valid-passwor
<system.net>
<mailSettings>
<smtp from="some-email@gmail.com">
<network enableSsl="true" host="smtp.gmail.com" port="587" userName="some-email@gmail.com" password="valid-password" />
</smtp>
</mailSettings>
</system.net>
是否仍然可以在代码中设置SMTP设置?我希望避免将密码保存在web.config文件中 使用具有所需属性的SmtpClient调用
SmtpClientWrapper
SmtpClient client = new SmtpClient("mail.example.com", 995);
SmtpClientWrapper wrapper = new SmtpClientWrapper(client);
我仍然有一个错误,在执行此操作时未指定SMTP主机…我想我需要找到一种方法将包装分配给MVCMailer。啊,好的,我发现了这一点-您需要将包装传递给Send方法。谢谢:)
SmtpClient client = new SmtpClient("mail.example.com", 995);
SmtpClientWrapper wrapper = new SmtpClientWrapper(client);