35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import 'server-only';
|
|
import type { BasePayload } from 'payload';
|
|
export type SendEmailArgs = {
|
|
/** Override the configured from-address for this message. */
|
|
from?: string;
|
|
/** HTML body. */
|
|
html: string;
|
|
/** Payload instance — used to read SMTP config from SiteIntegrations. */
|
|
payload: BasePayload;
|
|
replyTo?: string;
|
|
subject: string;
|
|
/** Optional plain-text fallback. */
|
|
text?: string;
|
|
to: string | string[];
|
|
};
|
|
export type SendEmailResult = {
|
|
error: string;
|
|
sent: false;
|
|
} | {
|
|
messageId: string;
|
|
sent: true;
|
|
};
|
|
/**
|
|
* Sends an email using SMTP settings from the SiteIntegrations global.
|
|
*
|
|
* Reads config at call time (not at boot) so editors can change SMTP in the
|
|
* admin panel without a restart — consistent with the plugin's panel-managed
|
|
* model. `server-only` keeps the SMTP password out of any client bundle.
|
|
*
|
|
* Returns a result object rather than throwing, so callers (e.g. form
|
|
* submission) can handle failure without a try/catch and never leak SMTP
|
|
* details to the client.
|
|
*/
|
|
export declare function sendEmail({ from, html, payload, replyTo, subject, text, to, }: SendEmailArgs): Promise<SendEmailResult>;
|