SlideShare a Scribd company logo
1 of 48
Send and receive email on
AWS
For serverless developers
Jeshan G. Babooa
What you’ll learn about
What you’ll learn
1. Hello world: sending your first email
2. Using email templates with multiple receivers
3. Ensure email providers trust you (as an email sender)
4. Receive emails and process them with AWS Lambda
SES in 30 seconds
Sending your 1st email
Sending an email
Verify a receiver email address first at
https://console.aws.amazon.com/ses
Sending an email
Confirm verification request
Sending an email
Email receiver verified
Verify your domain
Sending from your own domain
Using your domain
Verify domain and increase trust
Using your domain
Example config at Godaddy
Sending an email
Setup the function at
https://console.aws.amazon.com/lam
bda
Sending an email
Basic info
Sending an email
Permissions for the function. See
https://github.com/jeshan/lambdatv/
blob/master/ses-intro/ses-send-
receive-email-policy-document.json
Sending an email
Basic info
Sending an email
Function body available at:
https://github.com/jeshan/lambdatv/
blob/master/ses-intro/send-email.js
Sending an email
Paste function code
Sending an email
Test the function
Sending an email
Success!
Email templates
<h1>Hello {{name}},</h1><p>Your favourite colour is
{{colour}}.</p>
Email templates
Steal this from:
https://github.com/jeshan/lambdatv/
blob/master/ses-intro/example-email-
template.json
{
"Template": {
"TemplateName": "Template1",
"SubjectPart": "Hey, {{name}}!",
"HtmlPart": "<h1>Hello {{name}},</h1><p>Your favourite
colour is {{colour}}.</p>"
}
}
aws ses create-template --cli-input-json file://example-email-template.json
Email templates
Your list of templates
Email templates
Create data needed to send emails
that use the template, e.g
https://github.com/jeshan/lambdatv/
blob/master/ses-intro/example-
email.json and script:
https://github.com/jeshan/lambdatv/
blob/master/ses-intro/email-
template.sh
{
"Source": "from@email.com",
"Template": "Template1",
"Destinations": [
{
"Destination": {
"ToAddresses": [
"first@email.com"
]
},
"ReplacementTemplateData": "{ "name":"Geek", "colour":"blue" }"
},
{
"Destination": {
"ToAddresses": [
"second@email.com"
]
},
"ReplacementTemplateData": "{}"
}
],
"DefaultTemplateData": "{ "name":"fellow nerd", "colour":"red" }"
}
aws ses send-bulk-templated-email --cli-input-json file://example-email.json
Email templates
Success!
Receiving email
Verifying a domain
Receiving email
Basic example: Logging emails received.
Code:
https://github.com/jeshan/lambdatv/blo
b/master/ses-intro/event-invocation.js
Receiving email
Working with Rule Sets
Receiving email
Create a receipt rule
Receiving email
Lambda action
Receiving email
Review rule details
Receiving email
Send an email at a valid email on your
domain
Receiving email
Success!
Receiving email
Arbitrary logic. Code:
https://github.com/jeshan/lambdatv/
blob/master/ses-intro/event-request-
response.js
Receiving email
Sending a bounce back
Receiving email
Use RequestResponse
Receiving email
Send a mail that would get rejected
Receiving email
Send a mail that would get rejected
1 more thing about
DKIM
via amazonses.com or not?
Other use cases
- More security: can reject emails based on company policy. Example: only
authenticated emails from certain domains may be received.
- Support team: you can create support tickets on receiving emails at a certain
address with the description as whatever was in the email body.
- Receiving files: You can make it easy for people to send you files, e.g give
them an address to send attachments and use Lambda to process them.
- Archive emails: incoming emails can be saved to S3. for this one, you don’t
need to write a function, it’s supported directly by SES.
To see example functions from AWS that control mail flow:
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-
lambda-example-functions.html
Testing the sending
The emails are like this: x@simulator.amazonses.com where x =
- success
- bounce
- complaint
To learn more:
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/mailbox-
simulator.html
Monitor activity
Sending statistics dashboard
https://console.aws.amazon.com/ses/home#dashboard:
Monitor activity
Reputation dashboard
https://console.aws.amazon.com/ses/home#reputation-dashboard:
Going to production
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html
Notes
1. Do not use your personal email domain!
2. Ensure priority level for MX is high enough (e.g 0).
3. SES is a per-region service.
4. SES needs the lambda:addPermission IAM permission.
A couple of good resources
Show me the code
https://github.com/jeshan/lambdatv/tree/master/ses-intro
If you want the written
guide, incl. links:
https://www.lambdatv.com/send-and-receive-email-for-serverless-developers
Thanks for watching!
Jeshan G. Babooa
LambdaTV.com

More Related Content

What's hot

Workshop: Deploy a Deep Learning Framework on Amazon ECS
Workshop: Deploy a Deep Learning Framework on Amazon ECSWorkshop: Deploy a Deep Learning Framework on Amazon ECS
Workshop: Deploy a Deep Learning Framework on Amazon ECSAmazon Web Services
 
AWS Concepts - Internship Presentation - week 10
AWS Concepts - Internship Presentation - week 10AWS Concepts - Internship Presentation - week 10
AWS Concepts - Internship Presentation - week 10Devang Garach
 
Announcing AWS Personal Health Dashboard - January 2017 AWS Online Tech Talks
Announcing AWS Personal Health Dashboard - January 2017 AWS Online Tech TalksAnnouncing AWS Personal Health Dashboard - January 2017 AWS Online Tech Talks
Announcing AWS Personal Health Dashboard - January 2017 AWS Online Tech TalksAmazon Web Services
 
DevOps for the Enterprise: Automating Deployments
DevOps for the Enterprise: Automating DeploymentsDevOps for the Enterprise: Automating Deployments
DevOps for the Enterprise: Automating DeploymentsAmazon Web Services
 
Aws certification training guruprasanth.s
Aws certification training guruprasanth.sAws certification training guruprasanth.s
Aws certification training guruprasanth.sGURUPRASANTH33
 
Effective use of amazon web services for web deployment
Effective use of amazon web services for web deploymentEffective use of amazon web services for web deployment
Effective use of amazon web services for web deploymentGhazanfar Latif (Gabe)
 
AWS CodeDeploy
AWS CodeDeploy AWS CodeDeploy
AWS CodeDeploy Ratan Das
 
Code Deploy
Code Deploy Code Deploy
Code Deploy HajOnSoft
 
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트Amazon Web Services Korea
 
Aws certification training bangalore
Aws certification training bangaloreAws certification training bangalore
Aws certification training bangaloreavinashapponix
 
Aws certification training course ppt
Aws certification training course pptAws certification training course ppt
Aws certification training course pptSukanyas17
 
Aws task 12 guruprasanth.s
Aws task 12 guruprasanth.sAws task 12 guruprasanth.s
Aws task 12 guruprasanth.sGURUPRASANTH33
 
How to install WordPress on AWS EC2 via Deploy4Me
How to install WordPress on AWS EC2 via Deploy4MeHow to install WordPress on AWS EC2 via Deploy4Me
How to install WordPress on AWS EC2 via Deploy4MeDeploy4Me
 
Aws primer Amazon Web Services
Aws primer Amazon Web ServicesAws primer Amazon Web Services
Aws primer Amazon Web ServicesMamun Rashid, CCDH
 
Deep Dive On Serverless App Development
Deep Dive On Serverless App DevelopmentDeep Dive On Serverless App Development
Deep Dive On Serverless App DevelopmentAmazon Web Services
 
Best Practices for Getting Started with AWS
Best Practices for Getting Started with AWSBest Practices for Getting Started with AWS
Best Practices for Getting Started with AWSAmazon Web Services
 

What's hot (20)

Storage and Compute
Storage and ComputeStorage and Compute
Storage and Compute
 
AWS Elastic Compute Cloud (EC2)
AWS Elastic Compute Cloud (EC2) AWS Elastic Compute Cloud (EC2)
AWS Elastic Compute Cloud (EC2)
 
Workshop: Deploy a Deep Learning Framework on Amazon ECS
Workshop: Deploy a Deep Learning Framework on Amazon ECSWorkshop: Deploy a Deep Learning Framework on Amazon ECS
Workshop: Deploy a Deep Learning Framework on Amazon ECS
 
Aws interview questions
Aws interview questionsAws interview questions
Aws interview questions
 
Amazon Lightsail
Amazon LightsailAmazon Lightsail
Amazon Lightsail
 
AWS Concepts - Internship Presentation - week 10
AWS Concepts - Internship Presentation - week 10AWS Concepts - Internship Presentation - week 10
AWS Concepts - Internship Presentation - week 10
 
Announcing AWS Personal Health Dashboard - January 2017 AWS Online Tech Talks
Announcing AWS Personal Health Dashboard - January 2017 AWS Online Tech TalksAnnouncing AWS Personal Health Dashboard - January 2017 AWS Online Tech Talks
Announcing AWS Personal Health Dashboard - January 2017 AWS Online Tech Talks
 
DevOps for the Enterprise: Automating Deployments
DevOps for the Enterprise: Automating DeploymentsDevOps for the Enterprise: Automating Deployments
DevOps for the Enterprise: Automating Deployments
 
Aws certification training guruprasanth.s
Aws certification training guruprasanth.sAws certification training guruprasanth.s
Aws certification training guruprasanth.s
 
Effective use of amazon web services for web deployment
Effective use of amazon web services for web deploymentEffective use of amazon web services for web deployment
Effective use of amazon web services for web deployment
 
AWS CodeDeploy
AWS CodeDeploy AWS CodeDeploy
AWS CodeDeploy
 
Code Deploy
Code Deploy Code Deploy
Code Deploy
 
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
AWS 고객사를 위한 ‘AWS 컨테이너 교육’ - 유재석, AWS 솔루션즈 아키텍트
 
Aws certification training bangalore
Aws certification training bangaloreAws certification training bangalore
Aws certification training bangalore
 
Aws certification training course ppt
Aws certification training course pptAws certification training course ppt
Aws certification training course ppt
 
Aws task 12 guruprasanth.s
Aws task 12 guruprasanth.sAws task 12 guruprasanth.s
Aws task 12 guruprasanth.s
 
How to install WordPress on AWS EC2 via Deploy4Me
How to install WordPress on AWS EC2 via Deploy4MeHow to install WordPress on AWS EC2 via Deploy4Me
How to install WordPress on AWS EC2 via Deploy4Me
 
Aws primer Amazon Web Services
Aws primer Amazon Web ServicesAws primer Amazon Web Services
Aws primer Amazon Web Services
 
Deep Dive On Serverless App Development
Deep Dive On Serverless App DevelopmentDeep Dive On Serverless App Development
Deep Dive On Serverless App Development
 
Best Practices for Getting Started with AWS
Best Practices for Getting Started with AWSBest Practices for Getting Started with AWS
Best Practices for Getting Started with AWS
 

Similar to Send and receive email for serverless developers

Ascertia Secure E Mail Server (Jul08)
Ascertia Secure E Mail Server (Jul08)Ascertia Secure E Mail Server (Jul08)
Ascertia Secure E Mail Server (Jul08)andrei_gosman
 
Deploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCDeploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCGR8Conf
 
Choosing domain and IP address for Salesforce Marketing Cloud
Choosing domain and IP address for Salesforce Marketing CloudChoosing domain and IP address for Salesforce Marketing Cloud
Choosing domain and IP address for Salesforce Marketing CloudArek Rafflewski
 
(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes
(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes
(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 MinutesAmazon Web Services
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPSudheer Satyanarayana
 
Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)
Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)
Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)Vmoksha Admin
 
Amazon Simple Email Service
Amazon Simple Email ServiceAmazon Simple Email Service
Amazon Simple Email Servicechrisawheeler
 
The iot acdemy_awstraining_part4_aws_lab
The iot acdemy_awstraining_part4_aws_labThe iot acdemy_awstraining_part4_aws_lab
The iot acdemy_awstraining_part4_aws_labThe IOT Academy
 
AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...
AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...
AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...Amazon Web Services
 
Alexa101 course slides
Alexa101 course slidesAlexa101 course slides
Alexa101 course slidesDan Bloy
 
KingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_GmailKingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_GmailKingsley Usen
 
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrapNode mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrapKaty Slemon
 
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIsAmazon Web Services
 
Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Codemotion
 
Deep Dive on Amazon SES What's New - AWS Online Tech Talks
Deep Dive on Amazon SES What's New - AWS Online Tech TalksDeep Dive on Amazon SES What's New - AWS Online Tech Talks
Deep Dive on Amazon SES What's New - AWS Online Tech TalksAmazon Web Services
 

Similar to Send and receive email for serverless developers (20)

Ascertia Secure E Mail Server (Jul08)
Ascertia Secure E Mail Server (Jul08)Ascertia Secure E Mail Server (Jul08)
Ascertia Secure E Mail Server (Jul08)
 
Deploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCDeploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPC
 
Choosing domain and IP address for Salesforce Marketing Cloud
Choosing domain and IP address for Salesforce Marketing CloudChoosing domain and IP address for Salesforce Marketing Cloud
Choosing domain and IP address for Salesforce Marketing Cloud
 
(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes
(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes
(ISM317) Amazon WorkMail: Corporate Email in Less Than 10 Minutes
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHP
 
Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)
Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)
Setting up an email engine using amazon ses (vmokhsa technologies pvt. ltd.)
 
AWS SES
AWS SESAWS SES
AWS SES
 
Amazon Simple Email Service
Amazon Simple Email ServiceAmazon Simple Email Service
Amazon Simple Email Service
 
Amazon Simple Email Service 101
Amazon Simple Email Service 101Amazon Simple Email Service 101
Amazon Simple Email Service 101
 
Odoo Experience 2018 - Emails in Odoo
Odoo Experience 2018 - Emails in OdooOdoo Experience 2018 - Emails in Odoo
Odoo Experience 2018 - Emails in Odoo
 
The iot acdemy_awstraining_part4_aws_lab
The iot acdemy_awstraining_part4_aws_labThe iot acdemy_awstraining_part4_aws_lab
The iot acdemy_awstraining_part4_aws_lab
 
AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...
AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...
AWS re:Invent 2016: How Netflix Achieves Email Delivery at Global Scale with ...
 
Alexa101 course slides
Alexa101 course slidesAlexa101 course slides
Alexa101 course slides
 
KingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_GmailKingsleyUsen_SRS_Gmail
KingsleyUsen_SRS_Gmail
 
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrapNode mailer example how to send email using nodemailer with gmail &amp; mailtrap
Node mailer example how to send email using nodemailer with gmail &amp; mailtrap
 
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs
 
EmaiL Parser
EmaiL ParserEmaiL Parser
EmaiL Parser
 
Workshop: We love APIs
Workshop: We love APIsWorkshop: We love APIs
Workshop: We love APIs
 
Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...
 
Deep Dive on Amazon SES What's New - AWS Online Tech Talks
Deep Dive on Amazon SES What's New - AWS Online Tech TalksDeep Dive on Amazon SES What's New - AWS Online Tech Talks
Deep Dive on Amazon SES What's New - AWS Online Tech Talks
 

Recently uploaded

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 

Recently uploaded (20)

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 

Send and receive email for serverless developers

Editor's Notes

  1. Hi I’m Jeshan and welcome to the 4th episode of Lambda TV where I explore serverless on AWS.
  2. In this video you’ll learn about the basics of sending and receiving email in a serverless application
  3. 4 main things that you’ll learn by the end of this video
  4. Before we start, let me quickly give an overview of SES for those who aren’t familiar with it. Simple Email Service allows you to send and receive email at large scale and at a low cost. You can use it programmatically to send notifications, marketing, transactional emails, etc. You can also accept or reject incoming email according to your custom needs. SES handles a lot of the heavy lifting for you. It was originally built to handle Amazon.com’s email needs so you can be sure that SES will meet your reliability requirements.
  5. Let me walk you through how you can send your first email with AWS Lambda
  6. By default your account is in a sandbox. That means that for now you can only send to addresses that you have verified. So, the first step is to verify an address. Go to the SES console and follow the steps in the screenshot. You may use an address from any email provider at this point.
  7. You’ll get an email as follows
  8. It will then show as status ‘verified’ in the Identity Management section.
  9. Also, you may only use sender addresses on domains that you have verified. So you need to verify a domain as shown in the screenshot. You may want to take an additional step to secure your emails. You as a new email sender does not have credibility. Emails may have been intercepted by attackers. Or for the rest of us, you may just be a new spammer. Email providers may reject you based on arbitrary rules. So you need to authenticate your emails. What I’m talking about here is DKIM, meaning: DomainKeys Identified Mail. Like the name suggests, you set it up at domain level by adding DNS records. That’s why I ticked the Generate DKIM Settings at number 4 here.
  10. On the next screen, you’ll get DNS records to enter at your domain registrar. Enter all records shown there.
  11. For example, I would enter my MX record at GoDaddy as follows. SImilarly, enter all the other records shown in the previous slide. After DNS changes propagates, you may move on on this tutorial…
  12. Next, you create a lambda function as usual
  13. Add some basic info
  14. Also, we’ll create a new role so that the Lambda function has permission to use SES. (Note that the sendBounce permission will be used later in the tutorial; so you can put it there right now) No need to type this policy document; you can follow the link on-screen to get it
  15. Finalise the function creation. Next I’m going to show you the code that you can copy paste in there.
  16. The code that you’ll need is at the link on-screen. The 2 salient points in the function are numbered here. The first is to get a reference to the SES class, then call the sendEmail API.
  17. To test this function, create a test event at the top right and pass in toAddresses (which can be a string or an array of strings), and a source (which is an address that the email will appear to originate from).
  18. Click save, then test and you should receive an email like the following. Congrats, you’ve sent your first email using Amazon SES via Lambda. Remember that toAddresses property can also be an array. So, this tells you that you can have multiple receivers for the email. Feel free to try it before proceeding.
  19. You may want to keep your email designs separate from your code. In this case, you can use email templates. Usually, you could use a library to handle the templates but it turns out that SES has built-in support for email templates. For example, you can write a template like the above. What does the name placeholder above tell you? That this template can be used for multiple recipients with each having different values in the placeholders. you can have placeholders as part of the subject. This is useful when sending personalised emails.
  20. The first step is to define a template in a json file. For this tutorial, I saved the following json in a file called example-email-template.json. You can copy it from the github link shown. You create an email template by calling the createTemplate api.
  21. Later, you can locate all your created templates at the following page (though you currently can’t do much about it from there):
  22. Then create a second json file that will contain the remaining data needed to send an email, like recipients and placeholder values. Here, I put the following json in a file called example-email.json. The “ReplacementTemplateData” will be read and will take place of the placeholders. You’ll notice that I have 2 recipients, first@email.com and second@email.com and the second one doesn’t have any template data. In this case, the “DefaultTemplateData” will be used as default values for the placeholders. To send this email, invoke the sendBulkTemplatedEmail api.
  23. As expected, I got 2 emails. The second one had default values of “fellow nerd” and “red” populated. So far, you’ve seen how to send emails to one or more people and you have also seen how to send personalised emails using templates. Now, you’re going to see how to take action on received email on SES. It was surprising to me that receiving emails has hardly been covered in online tutorials as compared to sending emails. This is a powerful feature from SES. You can do take actions on the emails like archive them, send notifications. Besides, the ability to integrate with Lambda means that you arbitrarily decide what emails you want to accept, reject, forward, and many more things that you may imagine.
  24. You may have already verified a domain as shown earlier in this tutorial. But just to recap, you need to verify a domain so that SES knows about it. Verify a domain as in the screenshot
  25. I’ll start with a simple example that simply logs incoming emails. Let’s get this simple use case working first and after that, I’m going to show you a slightly more involved example. Create a function with the function showed. I have omitted the slides for it here since I’m sure you can handle this part.
  26. To receive emails with SES, you need certain addresses or domains that you want to monitor. Then you tell SES what Lambda function to process this email. You do both of this in a rule set. You need to create at least one rule in the rule set. So, start creating one as shown here.
  27. Step 1 is to define which verified domains or addresses you want to monitor
  28. Add a Lambda action, then choose the function that you created earlier. Leave the invocation type as Event. Event is for asynchronous processing, so that means that SES won’t wait for the function execution to complete in order to proceed. After this example is working, I’ll show you how to use RequestResponse. You may add more actions but I’m going to cover only single-action rules in this tutorial.
  29. Choose a rule name and finalise the rule creation:
  30. Now your rule set is active and ready to accept emails. Send an email to an address that matches the rule just created. Within a minute or two, you’ll see the log appear in Cloudwatch:
  31. Good. Logging works. We can try a more sophisticated example now. I’m going to show an example on how you can accept or reject emails based on arbitrary logic. Here, I’ll demonstrate how to reject emails from a certain domain but it can be any criteria you like.
  32. Here, I’ll “reject” the email by sending a bounce back to the original sender. Change the function body to the one given in the event-request-response.js file. Here, we’re saying that if we get emails from the jeshan.co domain, we would like to respond with a bounce. Otherwise, proceed with executing the rule set as usual. Change this domain to any other valid one, e.g gmail.com At the end of the handler, call the callback function with no parameters to indicate normal completion.
  33. The sendBounce function further down looks as follows. You need to set a bounce type, then call the sendBounce api. Maybe you’d also want to give the receiver an explanation of why you made the email bounce. You may also set the disposition to stop_rule_set which won’t execute further rules or actions in the rule set(but in this case it makes no difference since there’s only 1 rule in the rule set).
  34. Before we used the Event invocation type. This called our function asynchronously. But here, we want to control the mail flow so we need to call our function synchronously. You do that by changing the invocation type to RequestResponse. After you do that, send an email again to a matched recipient from the email domain that you entered in the function.
  35. Sending a stupid email as example here:
  36. After a few seconds, you should get a bounce like the following: “We’re rejecting your email because your domain sucks”
  37. By the way, you’re seeing in the screenshots that sometimes the “via amazonses.com” is shown (don’t know how other providers handle this). This is because my sender address was from a domain that I didn’t have DKIM set up. If you don’t want people to see this, it will serve you well to set up DKIM from the get-go as I showed in the beginning.
  38. Now, hopefully you get the picture of how arbitrary email processing works with Lambda. I’m sure you can imagine many more use cases. Lambda and Simple Notification Service (SNS) serve as your extension points here. So anything you can do with Lambda or SNS can be combined with SES. Here are some ideas you can consider: (read the slides) By the way other integrations are supported but I focus on Lambda because, well, this channel is called LambdaTV :)
  39. Use the mailbox simulator to test scenarios like bounces and complaints. It will especially be useful if you use SES alongside SNS. Otherwise, it won’t be that useful because SNS is the primary way of receiving notifications from the simulator. The emails are like this: ….. x@simulator.amazonses.com where x = success bounce Complaint
  40. It is recommended that you monitor your email activity, especially for numbers like bounce, complaint and reject rates. If your emails are perceived as spam but keep on sending emails, SES or email providers will penalise you. You should have a mechanism to handle bounces, complaints and rejects. AWS will ask you if you have these when going to production. You can monitor these things via the API or also in the console at the following dashboards. Here’s the first:
  41. … and the second. To learn more, watch the videos that I’ll link to at the end. Very important before going to production.
  42. … speaking of which: Restrictions apply by default because AWS needs to protect the credibility of SES with email providers. To send to any addresses, not just to those that you verified, you need to request production access as described in the following link. And some things to keep in mind while following this tutorial:
  43. Do not use your personal email domain! I used my personal email domain to send and receive emails with SES, not realising that this was preventing me from receiving any emails in regular inbox at Google. Don’t be as stupid as me. Ensure priority level for MX is high enough (e.g 0). The mistake I did was using something other than 0 and waiting for hours to get my Lambda function to get invoked… only to realise later that another higher priority MX record was being chosen. SES is a per-region service so any configuration applies per region, even verified emails and domains. SES needs the lambda:addPermission IAM permission. This is done automatically if you’re creating rule sets via the SES console but it may not be the case through the API.
  44. I have chosen these 2 re:Invent sessions for you to learn about it in more detail. You’ll learn many things from AWS people, including high-level discussion on implementing use cases and handling cases like bounces and complaints. The latter are very important for your credibility. Click the image on the slides to get access the videos.
  45. You can find all code discussed in this video at the github link on screen.
  46. If you want access to the guide and all resources mentioned, head over to the website at the link on screen
  47. Hope you liked this tutorial. If you like such videos about integrating serverless with AWS services and would like to see more, subscribe below. Thanks!