gpt4 book ai didi

asp.net - 使用 smtp 和 Outlook.Office365.com 发送电子邮件

转载 作者:行者123 更新时间:2023-12-01 11:31:09 25 4
gpt4 key购买 nike

我越来越无法使用 outlook.office365.com 和 ASP.NET 发送电子邮件。

我将联系表中的电子邮件地址作为“FROM”电子邮件传递。如果我将联系表单输入的“发件人”地址更改为“no-reply@mydomain.com”,它就会起作用。如果您从邮件服务器所在的不同域发送电子邮件,显然缺少这一步。

这是我的错误:“System.Net.Mail.SmtpException:邮箱不可用。服务器响应是:5.7.60 SMTP;客户端没有作为此发件人发送的权限”。我查了一下,结果几乎告诉我要在我没有使用的 Outlook 客户端中设置权限。

请让我知道哪里出错了。谢谢

我正在使用以下身份验证来发送我的电子邮件:

//msg.From = new MailAddress("no-reply@plassonusa.com", "What's Up");
//This is the From I want to use. The 1st one is the only one that works
msg.From = new MailAddress(txtEmail.Text, "What's Up");
msg.To.Add(emailTo);
msg.Subject = "my subject";

msg.IsBodyHtml = true;
msg.Body = "foo";

msg.Priority = MailPriority.High;

var smtpClient = new SmtpClient("outlook.office365.com", 587)
{
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("no-reply@domain.com", "mypassword"),
EnableSsl = true
};

if (msg.To.Count > 0)
{
try
{
smtpClient.Send(msg);
}
catch (Exception ex)
{
var error = ex.ToString();
}

}

最佳答案

我通过对“发件人”使用相同的电子邮件 ID 来修复它,该电子邮件 ID 用作 SMTP 用户。

关于asp.net - 使用 smtp 和 Outlook.Office365.com 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31834797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com