问题描述
我们正在考虑迁移到 O365;但是,我们开发的软件使用我们当前的 Exchange 服务器向外部用户发送电子邮件,并在发生错误时发送到支持箱.
We are thinking about moving to O365; however, we developed software that uses our current Exchange server to send email both to external users as well as to a support box when errors occur.
我一直在对此进行测试,以确保我们现有的代码将继续与 O365 一起使用,但到目前为止,我还不是很成功.
I've been testing this to ensure that the code we have in place will continue to work with O365 but so far, I have not been very successful.
我尝试过使用 .Net 的 SmtpClient 和 MailKit 的 SmtpClient,但似乎都没有.我不断收到错误(这是来自 MailKit 的错误——.Net 错误类似)
I have tried using .Net's SmtpClient as well as MailKit's SmtpClient and neither one seems to work. I keep getting error (this is the error from MailKit -- the .Net error is similar)
AuthenticationInvalidCredentials:5.7.3 身份验证不成功[*.prod.exchangelabs.com]"
"AuthenticationInvalidCredentials: 5.7.3 Authentication unsuccessful [*.prod.exchangelabs.com]"
我可以使用我的代码中的凭据登录到 OWA —— 所以我知道凭据是有效的.不能通过 O356 发送电子邮件吗?是否需要在 Exchange 中进行任何特殊配置才能实现这一点?
I can use the credentials that I have in my code to log into OWA -- so I know the credentials are valid. Is it not possible to send email via O356? Is there any special configuration that has to happen in Exchange to make this possible?
这是我迄今为止尝试过的:
Here is what I've tried so far:
MailKit
var msg = new MimeMessage();
msg.From.Add(new MailboxAddress("Support","support@mydomain.com"));
msg.To.Add(new MailboxAddress("Me","me@mydomain.com"));
msg.To.Add(new MailboxAddress("External User","euser@externaldomain.com"));
msg.Subject = "Test";
msg.Body = new TextPart("plain"){
Text = "Here is a message for you"
};
using(var client = new SmtpClient()){
client.ServerCertificateValidationCallback = (s,c,h,e) => true;
client.AuthenticationMechanisms.Remove("XOAUTH2"); //Not sure what this does. Have tried with and without
client.Connect("smtp.office365.com", 587, MailKit.Security.SecureSocketOptions.StartTls);
client.Authenticate(new NetworkCredential("support@mydomain.com", "supportPwd"));
client.Send(msg);
client.Disconnect(true);
}
.Net SmtpClient 代码看起来与 MailKit 代码非常相似.
The .Net SmtpClient code looked very similar to the MailKit code.
- 有没有办法通过 O365 与许可用户一起发送?(上面的代码)
- 是否需要在 Exchange 或许可用户上进行任何特殊设置才能完成这项工作?(如果 1 的答案是肯定的)
- 是否可以通过凭据用户拥有代理发送"权限的共享邮箱发送电子邮件?
更新
我仍然收到相同的错误消息.我们确实为我们的域用户启用了 MFA.但是,我们有一项政策,当用户从受信任的位置(我们组织的 IP)登录时,他们不需要 MFA.我还将我们的 IP 列为受信任的 IP.在我看来,MFA 不应该是这里的问题.
I'm still getting the same error message. We do have MFA enabled for our domain users. However, we have a policy that does not require MFA for users when they are signing in from a trusted location (our org's IP). I also listed our IP as a Trusted IP. In my mind, MFA shouldn't be the issue here.
我知道凭据是正确的.我从代码中复制它们并在登录 M365 时将它们粘贴到登录屏幕中——我很好地进入了.
I know the credentials are correct. I copied them from the code and pasted them in to the login screen when signing into M365 -- and I got in just fine.
我做错了什么?
推荐答案
是的,你可以.
Yes, you can.
用户设置:
服务器设置:https://support.office.com/en-us/article/POP-IMAP-and-SMTP-settings-for-Outlook-com-d088b986-291d-42b8-9564-9c414e2aa040p>
Server-settings : https://support.office.com/en-us/article/POP-IMAP-and-SMTP-settings-for-Outlook-com-d088b986-291d-42b8-9564-9c414e2aa040
SMTP server name smtp.office365.com
SMTP port 587
SMTP encryption method STARTTLS
- 不,你不能.您需要获得许可的用户才能通过 SMTP 发送邮件.
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365admin/set-up-smtp-relay-with-shared-mailbox/d7b98214-9564-432c-b098-525a98c529fb
我们的一个客户有一个使用 TYPO3 设置的时事通讯系统,我们必须为此创建一个新邮箱.但是,一个简单的就足够了:我们只分配了 Office 365 F1 许可证,而不是 Office 365 商业高级版.
A customer of ours has a newsletter system set up with TYPO3 and we had to create a new mailbox for this. However, a light one will suffice: instead of a Office 365 Business Premium we only assigned a Office 365 F1 licence.
还发现:Office365 共享邮箱可以使用 SMTP 吗?
这篇关于我可以通过 Office365 共享邮箱发送 SMTP 电子邮件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!