Compare commits

..

2 Commits

Author SHA1 Message Date
b7c657a930 1.0.6 2019-10-27 22:53:22 +01:00
0a758cdb60 fix(core): update 2019-10-27 22:53:21 +01:00
3 changed files with 30 additions and 5 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/mailgun",
"version": "1.0.5",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -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",

View File

@ -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);
}
}