Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
b7c657a930 | |||
0a758cdb60 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/mailgun",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/mailgun",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"private": false,
|
||||
"description": "an api abstraction package for mailgun",
|
||||
"main": "dist/index.js",
|
||||
|
@ -40,14 +40,39 @@ export class MailgunAccount {
|
||||
/**
|
||||
* sends a SmartMail
|
||||
*/
|
||||
public sendSmartMail(smartmailArg: plugins.smartmail.Smartmail) {
|
||||
public sendSmartMail(smartmailArg: plugins.smartmail.Smartmail, toArg: string, dataArg = {}) {
|
||||
const domain = smartmailArg.options.from.split('@')[1];
|
||||
this.postFormData(`/${domain}/messages`, [
|
||||
const formFields: plugins.smartrequest.IFormField[] = [
|
||||
{
|
||||
name: 'from',
|
||||
type: 'string',
|
||||
payload: smartmailArg.options.from
|
||||
},
|
||||
{
|
||||
name: 'to',
|
||||
type: 'string',
|
||||
payload: toArg
|
||||
},
|
||||
{
|
||||
name: 'subject',
|
||||
type: 'string',
|
||||
payload: smartmailArg.getSubject(dataArg)
|
||||
},
|
||||
{
|
||||
name: 'html',
|
||||
type: 'string',
|
||||
payload: smartmailArg.getBody(dataArg)
|
||||
}
|
||||
]);
|
||||
];
|
||||
|
||||
for (const attachment of smartmailArg.attachments) {
|
||||
formFields.push({
|
||||
name: 'attachment',
|
||||
type: 'Buffer',
|
||||
payload: attachment.contentBuffer
|
||||
})
|
||||
}
|
||||
|
||||
this.postFormData(`/${domain}/messages`, formFields);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user