@techie04/xpresser-mailer
Advanced tools
Comparing version 0.0.3 to 0.1.0
/// <reference types="node" /> | ||
import { Address, AttachmentLike } from "nodemailer/lib/mailer"; | ||
import { Address, AttachmentLike, Attachment } from "nodemailer/lib/mailer"; | ||
import { Readable } from "stream"; | ||
export declare const sendMail: ($to: string | Address | Array<string | Address>, $subject: string, $message: string | Buffer | Readable | AttachmentLike, $messageType?: string) => Promise<void>; | ||
export declare const sendMail: ($to: string | Address | Array<string | Address>, $subject: string, $message: string | Buffer | Readable | AttachmentLike, $messageType?: string, $attachments?: Attachment[] | undefined) => Promise<void>; | ||
export declare type AttachmentType = Attachment; |
@@ -59,3 +59,3 @@ "use strict"; | ||
} | ||
const sendMail = async ($to, $subject, $message, $messageType = "html") => { | ||
const sendMail = async ($to, $subject, $message, $messageType = "html", $attachments) => { | ||
const from = config.get("from") || $.config.get("name"); | ||
@@ -66,3 +66,4 @@ const mail = { | ||
subject: $subject, | ||
...($messageType === "html" ? { html: $message } : { text: $message }) | ||
...($messageType === "html" ? { html: $message } : { text: $message }), | ||
...($attachments && { attachments: $attachments }) | ||
}; | ||
@@ -69,0 +70,0 @@ await transporter.sendMail(mail); |
{ | ||
"name": "@techie04/xpresser-mailer", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "mailer helper for xpresser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -68,2 +68,13 @@ # XpresserJs Mailer Plugin | ||
(async () => { | ||
// array of attachments | ||
const attachments = [ | ||
{ | ||
// filename (optional) | ||
filename: "techieoriname.png", | ||
// file path or url | ||
path: path.join(__dirname, "..", "TechieOriname.png") | ||
} | ||
] | ||
await sendMail( | ||
@@ -73,3 +84,4 @@ "example@example.com", // to email | ||
"my message here", // message body | ||
"text" // message format ("html" or "text") | ||
"text", // message format ("html" or "text") | ||
attachments // optional field | ||
); | ||
@@ -82,4 +94,14 @@ }); | ||
```typescript | ||
import { sendMail } from "@techie04/xpresser-mailer"; | ||
import { AttachmentType, sendMail } from "@techie04/xpresser-mailer"; | ||
// array of attachments | ||
const attachments: AttachmentType[] = [ | ||
{ | ||
// filename (optional) | ||
filename: "techieoriname.png", | ||
// file path or url | ||
path: path.join(__dirname, "..", "TechieOriname.png") | ||
} | ||
]; | ||
await sendMail( | ||
@@ -89,4 +111,5 @@ "example@example.com", | ||
"my message here", | ||
"text" | ||
"text", | ||
attachments // optional field | ||
); | ||
``` |
19153
222
112