我最近在我们的项目中使用了 Mailkit lib,以替换 .NET SmtpClient。我们有 2 个使用 SmtpClient 发送电子邮件的业务案例。在一种情况下,我们使用 SmtpClient 在单独的进程中发送排队的电子邮件,而在另一种情况下,我们立即发送电子邮件。在实现时我注意到我们必须调用 Client 实例的 Disconnect 方法。
文档中不确定也不清楚调用此方法的最佳方法是什么。所以我的问题是,使用这种方法的最佳实践是什么?每条消息调用 mailClient.Disconnect(true) 还是 mailClient.Disconnect(false)?
mailClient.Disconnect(...);
出于兴趣,如果我在 using 块中使用客户端,是否需要在发送消息后显式调用 Disconnect(...) ?我认为它在执行 Dispose() 时隐式调用断开连接。
using (var mailClient = new SmtpClient())
{
mailClient.Connect(...);
mailClient.AuthenticationMechanisms.Remove("XOAUTH2");
mailClient.Authenticate(...);
mailClient.Send(message);
mailClient.Disconnect(false);
}
感谢您在这方面的反馈。
以下是我想在 TypeScript 中使用索引签名创建的类型。
export interface LoginState {
account: {
[userName: string]: string;
[password: string]: string;
};
}
Run Code Online (Sandbox Code Playgroud)
但是,我收到了这个问题标题中所述的错误。
该工具会提示/突出显示密码字段。
我找到了以下答案: Reactjs with Typescript 'Duplicate string index signature' 的错误 但这对我的问题没有帮助。
谁能指出我在这里犯的错误?
请随时询问是否需要进一步说明。
干杯,RSF
PS添加完整的组件实现:
import * as React from "react";
import { User } from "./../interfaces/User";
import { SecurityService } from "./../services/SecurityService";
export interface LoginProps {
onLogged: (user: User) => void;
}
export interface LoginState {
currentUser: User | null;
account: {
[userName: string]: string;
[password: string]: string;
};
}
export …Run Code Online (Sandbox Code Playgroud)