Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Send Email using AWS SES and Lambda

var aws = require('aws-sdk');
var ses = new aws.SES({
  region: 'ap-southeast-1' 
});
let subject = "";
let email_content = "";
let header = "";
let footer = "";
let to_email_address = [];
let bcc_email_address = [];
let cc_email_address = [];
let from_email_address = "";
exports.handler = function(event, context) {
var eParams = {
        Destination: {
            ToAddresses: to_email_address,
            CcAddresses: cc_email_address,
            BccAddresses:bcc_email_address
        },
        Message: {
            Body: {
                Html: {
                    Data: content,
                    Charset:'UTF-8'
                }
            },
            Subject: {
                Data: subject
            }
        },
        Source: from_email_address
};
var email = ses.sendEmail(eParams, function(err, data){
            if(err) {
               console.log(err.message);
               let result = {
                    success: 0,
                    statusCode: 500,
                    message: "Something went wrong in send email.",
                    body: {}
                };
                return result;
            } else {
                console.log("===EMAIL SENT===");
                console.log("EMAIL CODE END");
                console.log('EMAIL: ', email);
                console.log(data);
                let result = {
                    success: 1,
                    statusCode: 200,
                    message: 'Email sent successfully.',
                    body: {
                        
                    }
                };
                return result;
            }
 });
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: eject expo app to android and react native 
Javascript :: union of two objects javascript 
Javascript :: get all entries in object as array hjs 
Javascript :: get current time epoch javascript 
Javascript :: how to push at top of array 
Javascript :: datatable 
Javascript :: enzye check if it renders 
Javascript :: regular expression javascript password strength 
Javascript :: javascript object to base64 
Javascript :: how to install react router dom 
Javascript :: javascript lowercase string except first letter of every word if there are ' 
Javascript :: jquery select a dynamic element 
Javascript :: javascript caesar cipher 
Javascript :: javascript date method 
Javascript :: jquery animation 
Javascript :: E: Unable to locate package npm 
Javascript :: tocapitalize javascript 
Javascript :: js load js file 
Javascript :: reverse 179 in javascript 
Javascript :: Remove duplicate items form array using reduce() method. 
Javascript :: gulp runSequence 
Javascript :: avascript sum of arguments 
Javascript :: javascript select first n elements from array 
Javascript :: checkbox change event javascript 
Javascript :: icon refresh material ui 
Javascript :: jquery get radio checked value 
Javascript :: how to split text into array javascript 
Javascript :: get status of a user discord js 
Javascript :: datetime knex 
Javascript :: javascript alphabet array 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =