我可以通过Office365共享邮箱发送SMTP电子邮件吗? [英] Can I send SMTP email through Office365 shared mailbox?
问题描述
我们正在考虑迁移到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.
用户设置:
- 不,你不能.您需要获得许可的用户才能通过SMTP发送邮件.
我们的客户有一个使用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电子邮件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!