Using Amazon SES, You can send and receive email from your verified emails and domains. SES offers email receiving for entire domains or for individual addresses within a domain.We can use other AWS services S3(to store encrypted messages in bucket), SNS topic(to process the message, lamda function).
To send, receive, process the incoming messages, we have a package called django-ses-gateway
pip install django-ses-gateway
Things To Do Before Integration:
1. You must have an AWS account and you need to verify domain in SES to confirm that we are using those domains or to prevent from others using it. Once your domain is verified, then all your emails in the domain will also be verified.
AWS_ACCESS_KEY_ID = "Your AWS Access Key"
AWS_SECRET_ACCESS_KEY = "Your AWS Secret Key"
2.To use Amazon SES as your email receiver, you must create at least one active receipt rule set in which you have specified the sns topic(to route messages to an endpoint), s3 bucket(to store messages), lamda function(to process the receiving email) details.
3. After creating the rule set, for an sns topic you need to specify the list of recipients to which you want to process the message.
4. You need to subscribe to the specified SNS topic by providing your domain url(which handles email recieving) as an endpoint. You can give multiple enpoints which may either email, AWS SQS, HTTP or HTTPS.
5. In SES panel, you can also give a list of ip address to which you want reject the email receiving.
How amazon ses performs email receiving:
1. When user replies to an email, then it checks in the active receipt rule set(checks the specified email address, all addresses in the domain.) in the particular region.
2. If any rule set matches, then it checks against your IP address filters, and rejected if there any matches.
3. then after ses will store those messages in an crypted format using a key stored in AWS Key Management Service (KMS), publish the message to a specified SNS topic(endpoint).
1. Sending an email
from django_ses_gateway.receiving_mail import sending_mail
sending_mail(subject, email_template_name, context, from_email, to_email)
Here we are sending a from_mail as <unique-identifier>@yourdomain.com. Here unique identifier will be used to process the reply to thi mail.
2. Receiving an email
from django_ses_gateway.receiving_mail import sns_notification
subject, from_mail, to_mail, hash_code, mail_content = sns_notification(request.body)
Using the unique identifier(hash_code), we can easily process or store the incoming messages.
It will process your message content, will return the email subject, from mail, to email(firstname.lastname@example.org), hashcode(abc) or unique-identifier, mail content.
You can view the complete documentation here. http://django-ses-gateway.readthedocs.io/en/latest/
Github Repository: https://github.com/MicroPyramid/django-ses-gateway
Accessing the EC2 instance even if you loose the pem file is rather easy.
1. First, create a new instance by creating new access ...
When using Boto you can only List 1000 objects per request. So to obtain all the objects in the bucket. You can use s3's paginator.
Here You can learn about how to setup and deploy a Django application to Amazon Web Services (AWS).
Tools/technologies used: Python v2.7 Django ...
MicroPyramid - India
HIG499, 6th phase KPHB, Hyderabad, India - 500072, +91 9959166266
Monday - Friday : 10:00 - 19:00
MicroPyramid - USA
280 Moon Clinton Rd,STE D Moon Twp, Pittsburgh, Pennsylvania 15108, +1 5102300949
MicroPyramid - UAE
Khalifa Building(Near Old Nesto Super Market),Opp Fire Station, Sharjah, UAE 341246, +971 566061239