masohi-mail 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin/factory.js +12 -0
- package/lib/send-handler.js +0 -13
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -62,6 +62,18 @@ async function factory (pkgName) {
|
|
|
62
62
|
if (!text) text = stripper(html)
|
|
63
63
|
return { text, html }
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
send = async (payload = {}) => {
|
|
67
|
+
const { find } = this.lib._
|
|
68
|
+
let { to, cc, bcc, from, subject, message, conn, options = {} } = payload
|
|
69
|
+
const c = find(this.connections, { name: conn })
|
|
70
|
+
if (!c) throw this.error('notFound%s%s', this.print.write('connection'), `${conn}@masohiMail`)
|
|
71
|
+
from = c.options.auth.user // can't change from if using smtp
|
|
72
|
+
const { text, html } = await this.formatMessage(message, options)
|
|
73
|
+
if (options.subject) subject = options.subject
|
|
74
|
+
const resp = await c.instance.sendMail({ from, to, cc, bcc, subject, text, html })
|
|
75
|
+
return resp
|
|
76
|
+
}
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
|
package/lib/send-handler.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
async function send (payload = {}) {
|
|
2
|
-
const { find } = this.lib._
|
|
3
|
-
let { to, cc, bcc, from, subject, message, conn, options = {} } = payload
|
|
4
|
-
const c = find(this.connections, { name: conn })
|
|
5
|
-
if (!c) throw this.error('notFound%s%s', this.print.write('connection'), `${conn}@masohiMail`)
|
|
6
|
-
from = c.options.auth.user // can't change from if using smtp
|
|
7
|
-
const { text, html } = await this.formatMessage(message, options)
|
|
8
|
-
if (options.subject) subject = options.subject
|
|
9
|
-
const resp = await c.instance.sendMail({ from, to, cc, bcc, subject, text, html })
|
|
10
|
-
return resp
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default send
|