For test,
use sanbox domain and need to add authorized reception (reciver) and need to accept that mail, if need to get mails.
For production:
add new domain with valid custom domain and add these 2 TXT records in DNS provider.
----------------------------------------------------------------
in postfix, (/etc/postfix/main.cf)
add smtp credentials in file
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = static:postmaster@xxxxxxxx.mailgun.org:PASSWORD
relayhost = smtp.mailgun.org
smtp_sasl_auth_enable = yes
================================
================================
AWS SES
in postfix, (/etc/postfix/main.cf)
relayhost = [email-smtp.us-west-2.amazonaws.com]:25
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
vim /etc/postfix/sasl_passwd
[email-smtp.us-west-2.amazonaws.com]:25 SMTP_USERNAME:SMTP_PASSWORD
Note: this username and pw are not IAM secret access key and access key. you have to create credentials. (SMTP settings -> create my smtp credentials [can create multiple credentials. all working] -> then it will generate username and pw. use those on above )
]postmap /etc/postfix/sasl_passwd
]hostname abc.com
]service restart postfix
]echo "Message" | mailx -r someone@fromaddress.com -s "important mail" someone@toaddress.com
=======================
How do I capture Amazon SES feedback notifications using AWS Lambda
https://www.youtube.com/watch?v=metiKh8u9rM
https://aws.amazon.com/premiumsupport/knowledge-center/lambda-sns-ses-dynamodb/
dynamodb
Table name: SESNotifications
Primary key: SESMessageId
Add sort key: SnsPublishTime
sns
create new topic-> Name: SESemailBouncesHasa
Goto SES --> verified email address --> click on the email --> Notifications --> edit configurations --> for Bounces, Complaints, Deliveries >> select:SESemailBouncesHasa --> save config
IAM role:
Name: lambda_ses_execution
Create Role --> trusted entity type, choose Lambda --> Permissions --> select AWSLambdaBasicExecutionRole --> Next --> Name:lambda_ses_execution --> done
Select created role --> Choose Add an Inline Policy (create policy) --> Service: DynamoDB --> action:PutItem (Write category)--> resources: DynamoDB table ARN --> Review -->name:lambda_ses_execution_policy --> Create policy.
ex:
------------------------IAM Policy Begins---------------------------
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1428510662000",
"Effect": "Allow",
"Action": [
"DynamoDB:PutItem"
],
"Resource": [
"arn:aws:DynamoDB:us-east-1:12345678912:table/SESNotifications"
]
}
]
}
------------------------IAM Policy Ends--------------------------
Then attach above policy to existing role call lambda_ses_execution
Lambda
Create function --> Blueprints --> search & click:sns-message -->
Lambda function code:
--------------------------Lambda Code Begins------------------------
console.log('Loading event');
var aws = require('aws-sdk');
var ddb = new aws.DynamoDB({params: {TableName: 'SESNotifications'}});
exports.handler = function(event, context)
{
console.log('Received event:', JSON.stringify(event, null, 2));
var SnsPublishTime = event.Records[0].Sns.Timestamp
var SnsTopicArn = event.Records[0].Sns.TopicArn;
var SESMessage = event.Records[0].Sns.Message
SESMessage = JSON.parse(SESMessage);
var SESMessageType = SESMessage.notificationType;
var SESMessageId = SESMessage.mail.messageId;
var SESDestinationAddress = SESMessage.mail.destination.toString();
var LambdaReceiveTime = new Date().toString();
if (SESMessageType == 'Bounce')
{
var SESreportingMTA = SESMessage.bounce.reportingMTA;
var SESbounceSummary = JSON.stringify(SESMessage.bounce.bouncedRecipients);
var itemParams = {Item: {SESMessageId: {S: SESMessageId}, SnsPublishTime: {S: SnsPublishTime},
SESreportingMTA: {S: SESreportingMTA}, SESDestinationAddress: {S: SESDestinationAddress}, SESbounceSummary: {S: SESbounceSummary},
SESMessageType: {S: SESMessageType}}};
ddb.putItem(itemParams, function(err, data)
{
if(err) { context.fail(err)}
else {
console.log(data);
context.succeed();
}
});
}
else if (SESMessageType == 'Delivery')
{
var SESsmtpResponse1 = SESMessage.delivery.smtpResponse;
var SESreportingMTA1 = SESMessage.delivery.reportingMTA;
var itemParamsdel = {Item: {SESMessageId: {S: SESMessageId}, SnsPublishTime: {S: SnsPublishTime}, SESsmtpResponse: {S: SESsmtpResponse1},
SESreportingMTA: {S: SESreportingMTA1},
SESDestinationAddress: {S: SESDestinationAddress }, SESMessageType: {S: SESMessageType}}};
ddb.putItem(itemParamsdel, function(err, data)
{
if(err) { context.fail(err)}
else {
console.log(data);
context.succeed();
}
});
}
else if (SESMessageType == 'Complaint')
{
var SESComplaintFeedbackType = SESMessage.complaint.complaintFeedbackType;
var SESFeedbackId = SESMessage.complaint.feedbackId;
var itemParamscomp = {Item: {SESMessageId: {S: SESMessageId}, SnsPublishTime: {S: SnsPublishTime}, SESComplaintFeedbackType: {S: SESComplaintFeedbackType},
SESFeedbackId: {S: SESFeedbackId},
SESDestinationAddress: {S: SESDestinationAddress }, SESMessageType: {S: SESMessageType}}};
ddb.putItem(itemParamscomp, function(err, data)
{
if(err) { context.fail(err)}
else {
console.log(data);
context.succeed();
}
});
}
};
------------------------Lambda Code Ends----------------------------
Note: editable line ------> TableName: 'SESNotifications1'
Runtime: Node.js 4.3
Name: sesnotificationscode
Role: lambda_ses_execution
Dont enable trigger yet. --> create function
open created function --> add Triggers --> SNS trigger --> SNS topic :SESemailBouncesHasa --> enable --> save
Verify:
Best 5 merit casino 2021 - xn--o80b910a26eepc81il5g.online
ReplyDeleteBest 5 merit casino 2021. Sign up at meritcasino to 바카라 play slots and casino games for real money, get bonus for 메리트카지노총판 free play and win real money septcasino in our 5