c# - 从 Godaddy 服务器上的 Office365 发送邮件
问题描述
对于一个应用程序,我正在用 c# 编写一个 api 服务。该站点托管在 Godaddy 服务器上。我们也有一个 Office 365 帐户。我正在尝试通过此帐户凭据在我的 c# 代码中发送 main 。之前我们有elasticemail smtp 帐户。相同的代码正在使用弹性电子邮件帐户。但此代码不适用于 Office 365 帐户。
smtpClient.Host = "smtp.office365.com";
smtpClient.EnableSsl = true;
smtpClient.Port = 25;
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("my365email@domain.com");
MailAddress toAddress = new MailAddress("toaddress@yahoo.com");
smtpClient.Credentials = new System.Net.NetworkCredential("my365email@domain.com", "password");
message.From = fromAddress;
message.To.Add(toAddress);
message.Subject = "This is the subject line";
message.Body = "This is a test mail";
smtpClient.Send(message);
解决方案
推荐阅读
- java - Java类中使用Kotlin注解类
- c++ - C++ 标准是否定义了结构中成员函数的函数内定义是否必须具有静态链接?
- java - 始终添加到最后一个 Listitem 位置并保持它
- android - 如何在测验应用程序中检查洗牌数组的答案
- google-visualization - 具有多个数据的谷歌折线图
- python - 尝试在 python2 中创建有限的数字序列:IndexError(初学者)
- ios - 在 URLSession.shared.dataTask(with: url) 中执行SegueWithIdentifier
- c# - 将工作委托给彼此的 2 个虚拟方法的良好实践
- sql - sql server 中根级别的 sql 搜索
- linq - 当通用存储库与 List 一起使用时,Linq 到实体给出错误
目的