Amazon SES with Loopback's NodeMailer

1,124 views
Skip to first unread message

britztopher

unread,
Aug 11, 2014, 8:47:35 AM8/11/14
to loopb...@googlegroups.com
So I use Amazon SES for my email service, and I see that loopback uses NodeMailer.  Now I would like to keep all my datasources in a datasources.json file, however, I am finding myself creating a new datasource programmatically because I need to set up connection info for Amazon's servers (ie - username and password).  Is there a way to include a username, password, host, and port.  This would be a nice feature if it didnt already exist.  The ablity to change your transports for NodeMailer within the datasources.json file.


britztopher

unread,
Aug 11, 2014, 10:42:34 AM8/11/14
to loopb...@googlegroups.com

For example, my datasource JSON for email would include a transport tag like so:

transports: [
            {
                type: 'smtp',
                host: smtp_host,
                secureConnection: true,
                port: smtp_port,
                auth: {
                    user: smtp_user,
                    pass: smtp_password
                }
            }
        ]

This would add some great encapsulation because we wouldnt have to make our own datasource classes.  I can add a feature ticket to the project, so we can get this in the queue. Just let me know 

ritchie

unread,
Aug 11, 2014, 4:29:59 PM8/11/14
to loopb...@googlegroups.com
This should work. Are you specifying the same argument as node mailers `setupTransport()` method? The connector just calls `setupTransport()` for each transport supplied. Here is the source:

Florian Didron

unread,
Aug 13, 2014, 4:50:05 AM8/13/14
to loopb...@googlegroups.com
Hi britztopher

I'm also looking to use Amazon SES in a declarative manner. From what I understand, the idea would be to create a datasource.json entry with the corrrect type and settings, in our case :

"ses": {
   
"name": "ses",
   
"connector": "email",
   
"transports": [
     
{
       
"type": "ses",
       
"accessKeyId": "AWS accessKeyId",
       
"secretAccessKey": "AWS secretAccessKey",
       
"rateLimit": 1
     
}
   
]
 
}

We should then install the node mailer ses transport npm package that will be required when the email connector calls the
setupTransport method.

Now this is very theoritical, because I can't get my head around setting up a model with this datasource and invoking it on a rest endpoint to send an email.

Kind regards,

Florian

britztopher

unread,
Aug 13, 2014, 8:55:50 AM8/13/14
to loopb...@googlegroups.com
Yes, but you should never keep username's and passwords within your application's source code.  There is a feature ticket open where it is being discussed here:


Environment variables are definitely going to be used, however, there are other dominos that need to fall first before this can be done in the best fashion.  More specifically:

Reply all
Reply to author
Forward
0 new messages