Kirim Email Menggunakan AWS SES dan 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;
}
});
};
Cute Capybara