【发布时间】:2019-07-31 21:10:38
【问题描述】:
尝试通过 ProtonMail Bridge (https://protonmail.com/bridge) 使用 SMTP 发送电子邮件。它基本上充当用于发送安全电子邮件的本地 SMTP 服务器。
当尝试通过我的 .Net 应用程序发送时,我得到:
System.Net.Mail.SmtpException:身份验证失败。 在 System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) 在 System.Net.Mail.SmtpClient.GetConnection() 在 System.Net.Mail.SmtpClient.Send(MailMessage 消息) 在 D:\VisualStudio\EmailTest\EmailTest\Form1.cs:line 68 中的 EmailTest.Form1.sendButton_Click(Object sender, EventArgs e) 处
这是我的测试代码:
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("<my username>", "<ProtonMail bridge password>");
smtp.Host = "127.0.0.1";
smtp.Port = 1025;
smtp.Send("me@FakeEmail.com", "them@FakeEmail.com", "Test Message Subject", "Test Message Body");
我在尝试的时候也会遇到同样的异常
smtp.EnableSsl=true
当我获取确切的凭据/配置并将它们放入电子邮件客户端(Outlook 或类似的)时,它工作正常。
以前有人遇到过这个问题吗?有什么解决方法吗?
在线搜索时,我唯一能找到的就是确保在设置 Credentials 属性之前设置了 UseDefaultCredentials=false。但我已经这样做了。
【问题讨论】:
标签: c# smtpclient