AWS SES Nodejs SDK - email with dash bounces - node.js

I'm using the aws nodejs SES sdk and emails with to address with something like 'email#host-name.com' appear to all be bouncing even though they exist. Works for other emails without the dash.
I looked and the emails do look like they end up as query parameters, do I just need to individually url encode them? I dont get an error anymore, but I dont have any email address to test with.
var params = {
Destination: {
ToAddresses: [
'email#host-name.com'
]
},
Message: {
Body: {
Html: {
Data: body
}
},
Subject: {
Data: subject
}
},
Source: fromAddress
};
ses.sendEmail(params, function (err, data) {
if (err){
console.log(err, err.stack);
} else {
//sent
}
});

This ended up not having to do with the dash. The emails were bouncing because an AWS email service IP was blacklisted.

Related

Amazon Pinpoint SMS For India

I am trying to implement Amazon's Pinpoint SMS. There is a special requirement for India to send SMS. I have followed this Documentation and added EntityId and TemplateId as extra parameters to pinpoint.sendMessages. But when I do, I am getting.
UnexpectedParameter: Unexpected key 'EntityId' found in params.MessageRequest.MessageConfiguration.SMSMessage
UnexpectedParameter: Unexpected key 'TemplateId' found in params.MessageRequest.MessageConfiguration.SMSMessage
Code
Refrence: AWS Official Pinpoint SMS Doc
let params = {
ApplicationId: applicationId,
MessageRequest: {
Addresses: {
[destinationNumber]: {
ChannelType: 'SMS'
}
},
MessageConfiguration: {
SMSMessage: {
Body: body,
EntityId: entityID,
Keyword: registeredKeyword,
MessageType: messageType,
OriginationNumber: originationNumber,
SenderId: senderId,
TemplateId: templateID
},
}
}
};
//Try to send the message.
pinpoint.sendMessages(params, function (err, data) {
// If something goes wrong, print an error message.
if (err) {
console.log(err.message);
// Otherwise, show the unique ID for the message.
} else {
console.log(data)
// console.log("Message sent! "
// + data['MessageResponse']['Result'][destinationNumber]['StatusMessage']);
}
});
Migrating AWS-SDK from 2.467.0 to 2.850 solved my issue.

AWS SES Error: Email address is not verified

I am trying to send email using aws-sdk ses in nodejs.
While executing the code the response I am getting is:
message:
'Email address is not verified. The following identities failed the check in region US-EAST-1:xxxtestemailxxx#gmail.com',
code: 'MessageRejected'
I have already verified the sender as well as receiver email(destination email in a array).
On SES settings of aws console, it is showing the email is verified. I removed the email and then once again successfully verified it.
Last time(few months back) when I used it, everything was working fine.
Below is the screenshot of my aws console related to SES:
Also when I am sending the test email using aws console, its working fine. This is only happening when I am trying to send email using aws-sdk.
Does anyone knows what is wrong, just to be clear I am also posting the code below:
const send_email = function (email, subject, source, payload) {
console.log(email, subject, source, payload);
let email_param = {
Destination: {
ToAddresses: email
},
// ConfigurationSetName: 'XXXRANDOMTEXT_PLATFORM',
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: payload
}
// Text: {
// Charset: "UTF-8",
// Data: payload
// }
},
Subject: {
Charset: "UTF-8",
Data: subject
}
},
Source: source
};
let send_email = SES.sendEmail(email_param).promise();
send_email
.then(data => {
return true;
})
.catch(error => {
console.log('sending email error:', error);
return false
});
}
If your AWS account is still in the sandbox mode then you have to verify your sender, receiver etc. Go to the prod mod to have access to the full features.

Trying to Send Email Using Alexa and AWS SES. Email will send however Alexa will return and Error

I am writing an Alexa Skill where one of the functions is to request to send an email to a user using AWS SES.
When the utterance is said to send the email, the email will send however Alexa will always reply 'There was a problem with the requested skill's response'.
I have tested to make sure the 'getEmail' intent itself is working and it is.
I have also tried moving the function within the intent but this has the same results.
This is the function to send the email using SES which seems to be working:
function sendEmail (event, context, callback){
var params = {
Destination: {
ToAddresses: ["xyz#gmail.com"]
},
Message: {
Body: {
Text: { Data: "Hi. Here is your email"
}
},
Subject: { Data: "Here is an email"
}
},
Source: "abc#gmail.com"
};
ses.sendEmail(params, function (err, data) {
callback(null, {err: err, data: data});
if (err) {
console.log(err);
context.fail(err);
} else {
console.log(data);
context.succeed(event);
}
});
}
Here is the intent which call the sendEmail() function.
'getEmail': function () {
sendEmail();
var bodyTemplate1 = new Alexa.templateBuilders.BodyTemplate1Builder();
var template1 = bodyTemplate1.setTitle("email").setTextContent(makeRichText("email")).setBackgroundImage(makeImage(image)).build();
this.response.speak("Your email has been sent").renderTemplate(template1).shouldEndSession(true);
this.emit(':responseReady');
},
When I run this I would like for the email to send to the the device and Alexa to just say "Your Email has been sent". At the moment it is just the email that is sending and the device saying "There was a problem with the requested skill's response"
Here is the error message from AWS Cloud
Looking at logs, your callback(null, {err: err, data: data}); is the issue here. From the code that you posted, callback doesn't exist (will be undefined). It doesn't look like you need that there so you can remove it.
AWS SDK - SES.sendEmail
The "callback" is just your function that's passed as the second argument.

AWS-SES Email address is not verified. Gmail account

I have try to send email using AWS-SES when new customer registration.
But i got some error like this
Email address is not verified. The following identities failed the check in region US-EAST-1: mathuk22#gmail.com (Request ID: 2278b8eb-544e-11e9-bab8-536962476bb7)
Note: Am not verify mathuk22#gmail.com email id in my AWS-SES
Without verify email how can i send email ?
exports.emailSend = (req, res) =>{
var htmlContentData = req.body.htmlContentData; // html content
var htmlSubjectData = req.body.htmlSubjectData; // subject
var params = {
Destination: {
//BccAddresses: [],
//CcAddresses: [],
ToAddresses: ["mathuk22#gmail.com"]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: htmlContentData // html mail content
},
Text: {
Charset: "UTF-8",
Data: "Hello Charith Sample description time 1517831318946"
}
},
Subject: {
Charset: "UTF-8",
Data: htmlSubjectData // html mail subject
}
},
ReplyToAddresses: [],
Source: "source#example.com",
};
ses.sendEmail(params, function(err, data) {
if (err)
console.log(err, err.stack);
else
res.send(data);
});
}
Initially AWS puts your account in Sandbox where you need to verify the recipient email address, you need to contact AWS Support and ask them to move your Account to production, once account is in production and limits have been increased, you don't need to verify recipient "To" address. It doesn't cause additional cost.
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html
Do the following steps to verify email on AWS:

How to prevent SparkPost from changing urls in emails?

I use SparkPost to send emails from my node.js app.
However, all links are converted to urls such as: http://go.sparkpostmail1.com/f/a/EgvUoS2LdGPzMx-AURKwZA~~/AABUGAA~/RgRZK0BSP0EIAGukLuGW3OxXA3NwY1gEAAAAAFkGc2hhcmVkQgoAAVK7SFdpNVEbUhFuaWNvbGFzQGR1cmFuZC5jaAlRBAAAAABEUWh0dHBzOi8vZGlzaGx5Lm1lbnUvZC9XYXNoaW5ndG9uL1JlZ2VudF9UaGFpL0Jhc2lsX0phZS81NjBmMzk5MmQ0YWUxNTAzMDBmZWZmMGIiLEcCe30
I've tried to disable the "click_tracking" like this (see code sample below), but it's still not working. does anyone have an idea to configure SparkPost to send the emails "as is"?
var sparky = new SparkPost(process.env.SPARKPOST_API_KEY, {"open_tracking": false, "click_tracking": false});
sparky.transmissions.send({transmissionBody: transmissionBody}, function (err, res) {
if (err) {
console.log('Whoops! Something went wrong in sendEmail');
console.log(err);
} else {
console.log('sendEmail sent!');
}
});
open and click tracking isn't set when you instantiate the SparkPostobject, it's done in the transmissionBody via the options key like so:
var SparkPost = require('sparkpost');
var sp = new SparkPost('<YOUR API KEY>');
sp.transmissions.send({
transmissionBody: {
options: {
open_tracking: false,
click_tracking: false
},
content: {
from: 'testing#sparkpostbox.com',
subject: 'Hello, World!',
html:'<html><body><p>Testing SparkPost - the world\'s most awesomest email service!</p></body></html>'
},
recipients: [
{address: '<YOUR EMAIL ADDRESS>'}
]
}
}, function(err, res) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
} else {
console.log('Woohoo! You just sent your first mailing!');
}
});
Additionally you can see examples for transmissions using node-sparkpost here:
https://github.com/SparkPost/node-sparkpost/tree/master/examples/transmissions
This particular examples includes the options key:
https://github.com/SparkPost/node-sparkpost/blob/master/examples/transmissions/send_transmission_all_fields.js
Variables quoted as {{ foo }} are escaped.
Variables quoted as {{{ foo }}} are treated as raw HTML.
https://developers.sparkpost.com/api/template-language/#header-html-escaping

Resources