SparkPost / nodemailer-sparkpost-transport

Sparkpost transport for Nodemailer
Apache License 2.0
26 stars 13 forks source link

how to fix error SparkPostError: Bad Request #19

Closed hoanghiep1x0 closed 5 years ago

hoanghiep1x0 commented 7 years ago
const nodemailer = require('nodemailer');
var sparkPostTransport = require('nodemailer-sparkpost-transport');

const transporter = nodemailer.createTransport(sparkPostTransport({
    'sparkPostApiKey': 'cfc389be072f1d7b6117fd7c9a2ccc3c........',
    'options': {
        'open_tracking': true,
        'click_tracking': true,
        'transactional': true
    },
    'campaign_id': 'viralchain.net'
}));

  let _config = {
            from: config.mail.active.send,
            to: data.mail,
            subject: config.mail.active.sub,
            text: config.mail.active.text, // plain text body
            html: htmlTemplateEmail // html body
        }

  transporter.sendMail(_config, function (err, info) {
            if (err) {
                console.log('Error: ' + err);
                cb(err, null);
            } else {
                console.log('Success: ' + info);
                cb(null, info);
            }
        });

config like :

{ from: 'Viralchain.net',
  to: 'hoanghiep1x0@gmail.com',
  subject: 'Viralchain Send Mail active',
  text: 'active acount from link ',
  html: 'html template' }

error Error: SparkPostError: Bad Request

errors: [ { message: 'Invalid domain', description: 'No sending domain specified', code: '7001' } ], statusCode: 400 }

sorry i updated the key permissions so i got an error

hoanghiep1x0 commented 7 years ago

I updated only to send "Send via SMTP" !

errors.    name: 'SparkPostError'    lỗi: [{message: 'Forbidden.' },    statusCode: 403}

I try with localhost.