Author Topic: email configurations - GMail, AWS SES & AWS SMTP  (Read 5973 times)

HeneryH

  • Full Member
  • ***
  • Posts: 219
email configurations - GMail, AWS SES & AWS SMTP
« on: October 28, 2015, 10:17:23 PM »
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:
Code: [Select]
npm install nodemailer
Code: [Select]
var nodemailer = require('nodemailer');

 var transporter = nodemailer.createTransport({
   service: 'Gmail',
   auth: {
       user: 'user@gmail.com',
       pass: 'pw'
   }});

AWS-SMTP:
Code: [Select]
npm install nodemailer-smtp-transport
Code: [Select]
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:
Code: [Select]
npm install nodemailer-ses-transport
Code: [Select]
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:
Code: [Select]
  transporter.sendMail({
          from: 'info@maritimeopscorp.com',
          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);

  });
« Last Edit: March 01, 2018, 02:50:17 PM by Felix »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5938
  • Country: us
    • LowPowerLab
Re: email config - AWS SES
« Reply #1 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).

HeneryH

  • Full Member
  • ***
  • Posts: 219
Re: email config - AWS SES
« Reply #2 on: October 29, 2015, 01:59:46 PM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 5938
  • Country: us
    • LowPowerLab
Re: email config - AWS SES
« Reply #3 on: October 29, 2015, 03:04:01 PM »
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

  • Full Member
  • ***
  • Posts: 219
Re: email config - AWS SES
« Reply #4 on: November 09, 2015, 01:21:35 PM »
Changed my original post since I found the error in my attempts.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5938
  • Country: us
    • LowPowerLab
Re: email config - AWS SES
« Reply #5 on: November 09, 2015, 04:22:32 PM »
HeneryH - thanks for the update!