email configurations - GMail, AWS SES & AWS SMTP

Started by HeneryH, October 28, 2015, 10:17:23 PM

HeneryH

Perhaps a single thread (sticky?) with posts on how to configure for various providers.

Figured out my AWS SES problem.  For AWS, you can send email one of two ways, through the SMTP interface or through the AWD-SDK.  Here is the rub, when using the SMTP you use the SMTP credentials, when using the SDK you use your AWS credentials.

Here are three code samples that I confirmed to work.

gmail:
npm install nodemailer

var nodemailer = require('nodemailer');

 var transporter = nodemailer.createTransport({
   service: 'Gmail',
   auth: {
       user: '[email protected]',
       pass: 'pw'
   }});


AWS-SMTP:
npm install nodemailer-smtp-transport

var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');

var transporter = nodemailer.createTransport(smtpTransport({
    service: 'SES',
    auth: {
        user: 'AWS SMTP Key',
        pass: 'Secret Key'
    }
}));


AWS-SKD:
npm install nodemailer-ses-transport

var nodemailer = require('nodemailer');
var sesTransport = require('nodemailer-ses-transport');

var transporter = nodemailer.createTransport(sesTransport({
    accessKeyId: "Main AWS Access Key",
    secretAccessKey: "Secret Key,
    rateLimit: 5 // do not send more than 5 messages in a second
}));


For all three cases:
  transporter.sendMail({
          from: '[email protected]',
          to: req.query.to,
          subject: req.query.subject,
          text: req.query.text
  },
  function(err,info){
     if(err){
       res.send('error');
         } else {
       res.send('sent');
         }
         console.log(info);
         console.log(err);

  });


Felix

Sorry I'm not sure how to help, it's purely a matter of getting the settings right in nodemailer and making sure your SMTP server can accept the requests (it's enabled, has the rights etc).

HeneryH

Quote from: Felix on October 29, 2015, 09:50:21 AM
Sorry I'm not sure how to help, it's purely a matter of getting the settings right in nodemailer and making sure your SMTP server can accept the requests (it's enabled, has the rights etc).

Agree Felix.  This post is primarily for those of us in the community who may have experience with SES.

I may try an experiment to install postfix and route outbound mail through the postfix plug-in for nodemailer.

As an experiment at least.

Thanks

Felix

Well at least the discussion is open and if there's any success with AWS then this would be good for you or others to share their findings.

HeneryH

Changed my original post since I found the error in my attempts.

Felix

HeneryH - thanks for the update!