|
|
@@ -5,6 +5,7 @@ import { Attachment } from 'nodemailer/lib/mailer';
|
|
|
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
|
|
|
|
import { EmailGenerator } from './email-generator';
|
|
|
+import { EmailSender } from './email-sender';
|
|
|
import { EmailEventHandler } from './event-handler';
|
|
|
|
|
|
/**
|
|
|
@@ -208,50 +209,6 @@ export interface TestingTransportOptions {
|
|
|
onSend: (details: EmailDetails) => void;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @description
|
|
|
- * An EmailSender is responsible for sending the email, e.g. via an SMTP connection
|
|
|
- * or using some other mail-sending API. By default, the EmailPlugin uses the
|
|
|
- * {@link NodemailerEmailSender}, but it is also possible to supply a custom implementation:
|
|
|
- *
|
|
|
- * @example
|
|
|
- * ```TypeScript
|
|
|
- * const sgMail = require('\@sendgrid/mail');
|
|
|
- *
|
|
|
- * sgMail.setApiKey(process.env.SENDGRID_API_KEY);
|
|
|
- *
|
|
|
- * class SendgridEmailSender implements EmailSender {
|
|
|
- * async send(email: EmailDetails) {
|
|
|
- * await sgMail.send({
|
|
|
- * to: email.recipient,
|
|
|
- * from: email.from,
|
|
|
- * subject: email.subject,
|
|
|
- * html: email.body,
|
|
|
- * });
|
|
|
- * }
|
|
|
- * }
|
|
|
- *
|
|
|
- * const config: VendureConfig = {
|
|
|
- * logger: new DefaultLogger({ level: LogLevel.Debug })
|
|
|
- * // ...
|
|
|
- * plugins: [
|
|
|
- * EmailPlugin.init({
|
|
|
- * // ... template, handlers config omitted
|
|
|
- * transport: { type: 'none' },
|
|
|
- * emailSender: new SendgridEmailSender(),
|
|
|
- * }),
|
|
|
- * ],
|
|
|
- * };
|
|
|
- * ```
|
|
|
- *
|
|
|
- * @docsCategory EmailPlugin
|
|
|
- * @docsPage EmailSender
|
|
|
- * @docsWeight 0
|
|
|
- */
|
|
|
-export interface EmailSender {
|
|
|
- send: (email: EmailDetails, options: EmailTransportOptions) => void | Promise<void>;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @description
|
|
|
* A function used to load async data for use by an {@link EmailEventHandler}.
|