@explita/cloud-mail-client
Version:
A simple mail client for Node applications.
73 lines (72 loc) • 1.76 kB
TypeScript
export type ApiOptions = {
method?: "GET" | "POST" | "PUT" | "DELETE";
body?: Record<string, any>;
headers?: Record<string, string>;
[key: string]: any;
};
export type SendMailOptions = {
to: string | string[];
from: string;
subject: string;
html?: string;
text?: string;
replyTo?: string | string[];
cc?: string | string[];
bcc?: string | string[];
attachments?: {
filename: string;
content: Buffer | string;
contentType?: string;
}[];
headers?: Record<string, string>;
};
type SuccessResponse = {
success: true;
status: Status;
messageId: string;
createdAt: string;
};
type ErrorResponse = {
success: false;
error: {
code: ErrorCode;
message: string;
errors?: Record<string, string>;
};
};
type ErrorCode = "InvalidDomain" | "InvalidCredentials" | "RateLimitExceeded" | "Unknown";
export type SendMailResponse = SuccessResponse | ErrorResponse;
export type Email = {
id: string;
providerMsgId: string | null;
groupId: string | null;
serviceId: string;
from: string;
to: string[];
cc: string[];
bcc: string[];
replyTo: string[];
subject: string;
html: string | null;
text: string | null;
attachments: Attachement[];
headers: Record<string, string>;
status: Status;
createdAt: string;
updatedAt: string;
events: Event[];
};
type Attachement = {
filename: string;
content: Buffer | string;
contentType?: string;
};
type Event = {
id: string;
emailId: string;
type: Status;
meta: Record<string, any> | null;
occurredAt: string;
};
type Status = "ACCEPTED" | "SENT" | "DELIVERED" | "OPENED" | "CLICKED" | "FAILED";
export {};