masohi-mail 1.1.4 → 1.2.1

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.
@@ -1,5 +1,5 @@
1
- import smtp from '../lib/conn/smtp.js'
2
- import hostinger from '../lib/conn/hostinger.js'
1
+ import smtp from './lib/conn/smtp.js'
2
+ import hostinger from './lib/conn/hostinger.js'
3
3
  import nodemailer from 'nodemailer'
4
4
 
5
5
  async function factory (pkgName) {
@@ -63,17 +63,19 @@ async function factory (pkgName) {
63
63
  return { text, html }
64
64
  }
65
65
 
66
- send = async (payload = {}) => {
66
+ send = async ({ payload = {}, conn, source } = {}) => {
67
67
  const { find } = this.lib._
68
- let { to, cc, bcc, from, subject, message, conn, options = {} } = payload
69
68
  const c = find(this.connections, { name: conn })
70
- if (!c) return
69
+ const { data } = payload
70
+ data.options = data.options ?? {}
71
71
  // TODO: wrong layout...
72
- if (!c) throw this.error('notFound%s%s', this.print.write('connection'), `${conn}@masohiMail`)
73
- from = c.options.auth.user // can't change from if using smtp
74
- const { text, html } = await this.formatMessage(message, options)
75
- if (options.subject) subject = options.subject
76
- const resp = await c.instance.sendMail({ from, to, cc, bcc, subject, text, html })
72
+ if (!c) throw this.error('notFound%s%s', this.print.write('connection'), `masohiMail:${conn}`)
73
+ data.from = data.from ?? c.options.auth.user // can't change from if using smtp
74
+ const { text, html } = await this.formatMessage(data.message, data.options)
75
+ data.subject = data.options.subject ?? data.subject
76
+ data.text = text
77
+ data.html = html
78
+ const resp = await c.instance.sendMail(data)
77
79
  return resp
78
80
  }
79
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "masohi-mail",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
4
4
  "description": "Mail Handler for Masohi Messaging",
5
5
  "main": "index.js",
6
6
  "scripts": {