LowPowerLab Forum

Software support => Pi Gateway => Topic started by: HeneryH on October 28, 2015, 10:17:23 PM

Title: email configurations - GMail, AWS SES & AWS SMTP
Post by: HeneryH 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);

  });
Title: Re: email config - AWS SES
Post by: 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).
Title: Re: email config - AWS SES
Post by: HeneryH 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
Title: Re: email config - AWS SES
Post by: Felix 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.
Title: Re: email config - AWS SES
Post by: HeneryH on November 09, 2015, 01:21:35 PM
Changed my original post since I found the error in my attempts.
Title: Re: email config - AWS SES
Post by: Felix on November 09, 2015, 04:22:32 PM
HeneryH - thanks for the update!