-
-
Save jcollado/cd357d9728b76bd08ff8 to your computer and use it in GitHub Desktop.
var nodemailer = require('nodemailer'); | |
var sesTransport = require('nodemailer-ses-transport'); | |
var smtpPassword = require('aws-smtp-credentials'); | |
var mailOptions = { | |
from: '[email protected]', | |
to: '[email protected]', | |
text: 'This is some text', | |
html: '<b>This is some HTML</b>', | |
}; | |
function callback(error, info) { | |
if (error) { | |
console.log(error); | |
} else { | |
console.log('Message sent: ' + info.response); | |
} | |
} | |
// Send e-mail using AWS SES | |
mailOptions.subject = 'Nodemailer SES transporter'; | |
var sesTransporter = nodemailer.createTransport(sesTransport({ | |
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | |
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | |
region: process.env.AWS_REGION | |
})); | |
sesTransporter.sendMail(mailOptions, callback); | |
// Send e-mail using SMTP | |
mailOptions.subject = 'Nodemailer SMTP transporter'; | |
var smtpTransporter = nodemailer.createTransport({ | |
port: 465, | |
host: 'email-smtp.us-west-2.amazonaws.com', | |
secure: true, | |
auth: { | |
user: process.env.AWS_ACCESS_KEY_ID, | |
pass: smtpPassword(process.env.AWS_SECRET_ACCESS_KEY), | |
}, | |
debug: true | |
}); | |
smtpTransporter.sendMail(mailOptions, callback); |
@VictorMs The code in the example shows how to send an email using the AWS SES service using either the API or the SMTP interface. If you're interested in the SMTP interface, then please have a look at the following links:
https://nodemailer.com/smtp/
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-smtp.html
Hello. I'm new in SES. Can you explain me what email accounts can I can use with SES? Does SES provide its own email box? And can I, for example, send emails to gmail accounts? Does this somehow related to an AWS region?
@ProximaCentauri1989 It's been a while since I used SES for the last time.
In any case, I believe that you don't have any mailbox in SES, what you need to do is verify that you own the email address you're using as the source:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html
In terms of what email address can you use as destination, you should be able to send emails to any address you like.
Thanks!
Hello Jcollado,
Could you tell me where to run or use smtpTransporter , Thank you so much