简体   繁体   English

如何连接到 Microsoft Exchange Smtp?

[英]How to connect to Microsoft Exchange Smtp?

Usually, for Gmail and outlook we have app passwords to connect to SMTP (though we can use email passwords by enabling less secure app access).通常,对于 Gmail 和 Outlook,我们有应用程序密码来连接到 SMTP(尽管我们可以通过启用安全性较低的应用程序访问来使用电子邮件密码)。

But for my Microsoft Exchange mail I can't find the app password, nor I can connect my app with the mail to send emails.但是对于我的 Microsoft Exchange 邮件,我找不到应用程序密码,也无法将我的应用程序与邮件连接起来以发送电子邮件。

import smtplib
password = "mypassword"
email = "usrname@tsac-uae.com"
s = smtplib.SMTP('smtp.office365.com', 587)
s.starttls()
s.login(email, password)

I get an error saying我收到一条错误消息

smtplib.SMTPAuthenticationError: (535, b'5.7.139 Authentication unsuccessful, 
SmtpClientAuthentication is disabled for the Tenant. 
Visit https://aka.ms/smtp_auth_disabled for more information. 
[AM9P192CA0015.EURP192.PROD.OUTLOOK.COM]')

To avoid these complications, I need to use an app password.为了避免这些并发症,我需要使用应用密码。 But I can't find how to set up app password in exchange.但我找不到如何设置应用程序密码作为交换。 Also, the steps said in the website is outdated.另外,网站上说的步骤已经过时了。 I can't find enable SMTP anywhere.我在任何地方都找不到启用 SMTP。

You need to enable SMTP submission (an organization-wide setting) within your Microsoft Tenant as per the link you get in the error message, which expands to https://docs.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/authenticated-client-smtp-submission .您需要根据错误消息中获得的链接在 Microsoft 租户中启用SMTP 提交(组织范围的设置),该链接扩展为https://docs.microsoft.com/en-us/exchange/clients-and -mobile-in-exchange-online/authenticated-client-smtp-submission

The change can only be performed via powershell.更改只能通过 powershell 执行。 An easy way to perform this change is by logging in at https://shell.azure.com .执行此更改的一种简单方法是登录https://shell.azure.com To use Exchange Online cmdlets in the Azure Cloud Shell, the Exchange Online cmdlets need to be imported using Connect-EXOPSSession .若要在 Azure Cloud Shell 中使用 Exchange Online cmdlet,需要使用Connect-EXOPSSession导入 Exchange Online cmdlet。 Once connected, to enable SMTP submission use连接后,启用 SMTP 提交使用

Set-TransportConfig -SmtpClientAuthenticationDisabled $false 

Make sure you read the article linked above to understand the security implications.请务必阅读上面链接的文章以了解安全隐患。 Also beware that还要注意的是

If your authentication policy disables basic authentication for SMTP, clients cannot use the SMTP AUTH protocol even if you enable the settings outlined in this article.如果您的身份验证策略禁用了 SMTP 的基本身份验证,则即使您启用本文中概述的设置,客户端也无法使用 SMTP AUTH 协议。 For more information, see Disable Basic authentication in Exchange Online .有关详细信息,请参阅在 Exchange Online 中禁用基本身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自Microsoft Exchange服务器的响应中的星号而不是SMTP代码 - Asterisks instead of SMTP codes in response from Microsoft Exchange server Powershell,使用“里程”字段发送SMTP电子邮件(Microsoft Exchange) - Powershell, Send SMTP email with 'Mileage' field (Microsoft Exchange) 几次发送后无法连接到Microsoft Exchange - Could not connect to Microsoft Exchange after a few sends 如何使用Microsoft Exchange发送电子邮件附件? - How to send email attachments with microsoft exchange? 如何在不使用smtp的情况下通过Exchange服务器发送电子邮件? - How to send email via exchange server without using smtp? 如何使用没有公共 SMTP 的 Exchange 服务器通过 .NET 以编程方式发送电子邮件? (不是 SMTP) - How do I send emails programatically via .NET with an Exchange server that doesn't have a public SMTP? (NOT SMTP) 第二次如何连接smtp端口25? - How to connect smtp port 25 in second time? Outlook SMTP /交换行为差异 - Outlook smtp/exchange behavior differences smtp 邮件中的 smtp 连接失败 - smtp connect failed in smtp mail 可以使用 JavaMail 和 Apache Camel Mail (IMAP) 通过服务帐户连接 Microsoft Exchange 共享邮箱吗? - Possible to connect with a Microsoft Exchange shared mailbox via service account using JavaMail and Apache Camel Mail (IMAP)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM