我必须从nodejs应用程序发送一些邮件,如果凭据错误,我想从类的构造函数中抛出异常,我将使用该类来处理邮件,但我找不到方法来做到这一点; 我正在使用模块 ews-javascript-api 连接到 Exchange Server。
我尝试将测试邮件发送到虚假地址,但它不起作用,因为发件人方法返回一个 Promise,我无法从中抛出异常。
class ExchSender{
constructor(username, passowrd){
this.exch = new ExchangeService();
this.exch.Credentials = new ews.ExchangeCredentials(username, password);
this.exch.Url = new Uri('https://exchange.exch/ews/exchange.asmx');
//Here I'd like to test the connection and throw the exception
}
}
最佳答案
如果您只想检查凭据,请在 services.wsdl 上执行正常的 Get,这将需要身份验证。这并不真正检查 Exchange 连接,只是检查 IIS 是否可用以及凭据在端点上是否有效。正确的连接测试将查看您是否可以绑定(bind)到收件箱文件夹,因为这会告诉您邮箱可用,因为后端有很多东西可以使用 IIS 端点,例如商店可能离线、被移动或服务停止等。
关于javascript - 有没有测试 Exchange 连接的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56853681/