ecohealthalliance / parse-server-amazon-ses-email-adapter

Send parse-server template emails with Amazon SES.
Apache License 2.0
5 stars 15 forks source link

Getting this error #6

Open alifardoss opened 3 years ago

alifardoss commented 3 years ago

Error: Signature Version 3 requests are deprecated from March 1, 2021. From that date on, we are progressively rejecting such requests. To resolve the issue you must migrate to Signature Version 4. If you are self-signing your requests, refer to the documentation for Authenticating requests to the Amazon SES API [1] with Signature Version 4 [2]. If you are not self-signing your requests, simply update your SDK/CLI to the latest version. [1] https://docs.aws.amazon.com/ses/latest/DeveloperGuide/using-ses-api-authentication.html [2] https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

alifardoss commented 3 years ago

const AWS = require("aws-sdk");

AWS.config.update({ accessKeyId: process.env.AWS_ACCESS_KEY, secretAccessKey: process.env.AWS_SECRET_KEY, region:'us-west-2' });

const ses = new AWS.SES({ apiVersion: "2010-12-01" });

module.exports=function(options){ var sendMail=function(mail){ return new Promise(function(resolve, reject){ const params = { Destination: { ToAddresses: [mail.to] }, ReplyToAddresses:[options.from], Message: { Body: { Html: { Charset: "UTF-8", Data:mail.html }, Text: { Charset: "UTF-8", Data: mail.text ? mail.text : "" } }, Subject: { Charset: "UTF-8", Data: mail.subject } }, Source: options.from }; ses.sendEmail(params, function(error, data) { if (error) { reject(error); } else { resolve(data); } }) }); }; return { sendMail: sendMail } };

I suggest this coding structure without the need for another third party service... Just copy paste this and remove the process.env.. this method works and quickly adapts to AWS module changes

hamzabinamin commented 1 year ago

@alifardoss how do I integrate your code with the parse configuration file? I mean how would parse decide if its a password reset email or a verification one?