build
This commit is contained in:
parent
ae8f58ef47
commit
0bd528c6f4
|
|
@ -1,5 +1,30 @@
|
|||
/// <reference types="node" />
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
interface AttachmentLike {
|
||||
/** String, Buffer or a Stream contents for the attachment */
|
||||
content?: string | Buffer | undefined;
|
||||
/** path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments) */
|
||||
path?: string | undefined;
|
||||
}
|
||||
interface Attachment extends AttachmentLike {
|
||||
/** filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value as false, otherwise a filename is generated automatically */
|
||||
filename?: string | false | undefined;
|
||||
/** optional content id for using inline images in HTML message source. Using cid sets the default contentDisposition to 'inline' and moves the attachment into a multipart/related mime node, so use it only if you actually want to use this attachment as an embedded image */
|
||||
cid?: string | undefined;
|
||||
/** If set and content is string, then encodes the content to a Buffer using the specified encoding. Example values: base64, hex, binary etc. Useful if you want to use binary attachments in a JSON formatted e-mail object */
|
||||
encoding?: string | undefined;
|
||||
/** optional content type for the attachment, if not set will be derived from the filename property */
|
||||
contentType?: string | undefined;
|
||||
/** optional transfer encoding for the attachment, if not set it will be derived from the contentType property. Example values: quoted-printable, base64. If it is unset then base64 encoding is used for the attachment. If it is set to false then previous default applies (base64 for most, 7bit for text). */
|
||||
contentTransferEncoding?: "7bit" | "base64" | "quoted-printable" | false | undefined;
|
||||
/** optional content disposition type for the attachment, defaults to ‘attachment’ */
|
||||
contentDisposition?: "attachment" | "inline" | undefined;
|
||||
/** is an object of additional headers */
|
||||
headers?: Headers | undefined;
|
||||
/** an optional value that overrides entire node content in the mime message. If used then all other options set for this node are ignored. */
|
||||
raw?: string | Buffer | AttachmentLike | undefined;
|
||||
}
|
||||
export type EmailOptions = {
|
||||
host: string;
|
||||
port: number;
|
||||
|
|
@ -10,6 +35,7 @@ export type EmailOptions = {
|
|||
to: string;
|
||||
text?: string;
|
||||
html?: string;
|
||||
attachments?: Attachment[];
|
||||
};
|
||||
/**
|
||||
* 邮箱发送
|
||||
|
|
@ -21,3 +47,4 @@ export default interface Email<ED extends EntityDict> {
|
|||
error?: string;
|
||||
}>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import nodemailer from 'nodemailer';
|
|||
export default class Nodemailer {
|
||||
name = 'nodemailer';
|
||||
async sendEmail(options, context) {
|
||||
const { host, port, account, password, subject, from, text, html, to } = options;
|
||||
const { host, port, account, password, subject, from, text, html, to, attachments } = options;
|
||||
const transporter = nodemailer.createTransport({
|
||||
host,
|
||||
port,
|
||||
|
|
@ -36,6 +36,7 @@ export default class Nodemailer {
|
|||
subject,
|
||||
text,
|
||||
html,
|
||||
attachments: attachments
|
||||
};
|
||||
try {
|
||||
let info = await transporter.sendMail(mailOptions);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,30 @@
|
|||
/// <reference types="node" />
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
interface AttachmentLike {
|
||||
/** String, Buffer or a Stream contents for the attachment */
|
||||
content?: string | Buffer | undefined;
|
||||
/** path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments) */
|
||||
path?: string | undefined;
|
||||
}
|
||||
interface Attachment extends AttachmentLike {
|
||||
/** filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value as false, otherwise a filename is generated automatically */
|
||||
filename?: string | false | undefined;
|
||||
/** optional content id for using inline images in HTML message source. Using cid sets the default contentDisposition to 'inline' and moves the attachment into a multipart/related mime node, so use it only if you actually want to use this attachment as an embedded image */
|
||||
cid?: string | undefined;
|
||||
/** If set and content is string, then encodes the content to a Buffer using the specified encoding. Example values: base64, hex, binary etc. Useful if you want to use binary attachments in a JSON formatted e-mail object */
|
||||
encoding?: string | undefined;
|
||||
/** optional content type for the attachment, if not set will be derived from the filename property */
|
||||
contentType?: string | undefined;
|
||||
/** optional transfer encoding for the attachment, if not set it will be derived from the contentType property. Example values: quoted-printable, base64. If it is unset then base64 encoding is used for the attachment. If it is set to false then previous default applies (base64 for most, 7bit for text). */
|
||||
contentTransferEncoding?: "7bit" | "base64" | "quoted-printable" | false | undefined;
|
||||
/** optional content disposition type for the attachment, defaults to ‘attachment’ */
|
||||
contentDisposition?: "attachment" | "inline" | undefined;
|
||||
/** is an object of additional headers */
|
||||
headers?: Headers | undefined;
|
||||
/** an optional value that overrides entire node content in the mime message. If used then all other options set for this node are ignored. */
|
||||
raw?: string | Buffer | AttachmentLike | undefined;
|
||||
}
|
||||
export type EmailOptions = {
|
||||
host: string;
|
||||
port: number;
|
||||
|
|
@ -10,6 +35,7 @@ export type EmailOptions = {
|
|||
to: string;
|
||||
text?: string;
|
||||
html?: string;
|
||||
attachments?: Attachment[];
|
||||
};
|
||||
/**
|
||||
* 邮箱发送
|
||||
|
|
@ -21,3 +47,4 @@ export default interface Email<ED extends EntityDict> {
|
|||
error?: string;
|
||||
}>;
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const nodemailer_1 = tslib_1.__importDefault(require("nodemailer"));
|
|||
class Nodemailer {
|
||||
name = 'nodemailer';
|
||||
async sendEmail(options, context) {
|
||||
const { host, port, account, password, subject, from, text, html, to } = options;
|
||||
const { host, port, account, password, subject, from, text, html, to, attachments } = options;
|
||||
const transporter = nodemailer_1.default.createTransport({
|
||||
host,
|
||||
port,
|
||||
|
|
@ -39,6 +39,7 @@ class Nodemailer {
|
|||
subject,
|
||||
text,
|
||||
html,
|
||||
attachments: attachments
|
||||
};
|
||||
try {
|
||||
let info = await transporter.sendMail(mailOptions);
|
||||
|
|
|
|||
Loading…
Reference in New Issue