C# net\u io\u连接在c中尝试通过office365发送时发生关闭错误#

C# net\u io\u连接在c中尝试通过office365发送时发生关闭错误#,c#,.net,office365,smtpclient,C#,.net,Office365,Smtpclient,我已经查看了其他线程,到目前为止还没有找到解决方案。 每当我尝试通过下面的方法连接时,我都会收到net_io_connectionclosed错误 我正在尝试使用Office 365 smtp中继。我无法访问主帐户,也无法更改有关此电子邮件的任何内容,因此我无法检查设置,甚至无法重置密码 SmtpClient client = new SmtpClient("smtp.office365.com", 587); client.UseDefaultCredentials = false; clie

我已经查看了其他线程,到目前为止还没有找到解决方案。 每当我尝试通过下面的方法连接时,我都会收到net_io_connectionclosed错误

我正在尝试使用Office 365 smtp中继。我无法访问主帐户,也无法更改有关此电子邮件的任何内容,因此我无法检查设置,甚至无法重置密码

SmtpClient client = new SmtpClient("smtp.office365.com", 587);
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential(uname, pwd);
client.TargetName = "STARTTLS/smtp.office365.com";
client.Timeout = 10000;
client.Send(msg);
感谢所有的帮助

uname:中继帐户的电子邮件地址(无回复@[x].com)

我正在等待回复我的电子邮件,以获取onmicrosoft.com地址,但在任何教程中都没有提到。因此,此处的uname也在msg中作为“from”地址

pwd:密码

SmtpClient client = new SmtpClient("smtp.office365.com", 587);
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential(uname, pwd);
client.TargetName = "STARTTLS/smtp.office365.com";
client.Timeout = 10000;
client.Send(msg);

好的,事实证明,除非您拥有IP(不由Azure、netregistry等提供),否则使用中继是不可能的

你必须从O365购买一个新邮箱并使用它。因此,除非您运行自己的服务器(在这种情况下,我不需要中继,因为我将使用自己的smtp服务),否则就无法使用realy

这意味着,如果您运行的是Azure,可能最好避免使用O365发送电子邮件,其他供应商则更为灵活

链接至MS的论坛: