Download email attachment and upload S3 bucket AWS - amazon-s3

I have a web app hosted on aws under free tier limit. What I want to achieve is that whenever I received an email, i want the system to download its attachment(will be images only), upload that image to s3 and save the image id in database with email's sender email address. I don't want to use zapier api etc, I want to code it my self. How can I achieve this?

This really depends upon how your email is hosted.
You could use Receive Email with Amazon Simple Email Service.
The flow could then either be:
SES -> S3 -> Trigger Event -> AWS Lambda function, or
SES -> SNS -> AWS Lambda function
You would then need to write a Lambda function to do the processing you described.
If, on the other hand, your email is being hosted elsewhere, then you will need a mechanism to trigger some code when an email is received (somehow on your email system) or a scheduled Lambda function to poll the email system to see whether new mail is available.

Related

How to using Azure Board to trigger a API call or script

Is there a way I can set up a API call triggering in Azure Board? Lets say one item is "Request approval for creating S3 buckets in AWS", I want to trigger S3 creating API or script when this item's status changed from doing to done. My end goal is automating tasks like S3 buckets creation, VPC creation, shutdown/start VMs etc in my organization.
You are probably wanting to create a Webhook.
Webhooks provide a way to send a JSON representation of an event to
any service. All that is required is a public endpoint (HTTP or
HTTPS).
You would setup to trigger on work item updated. You would like need to code on your receiver to interpret the update.
A. If you want to trigger the API via work item state update, you need own website to receive message from VSTS web hook and send request to run the API call or script, and create webhook in the Azure DevOps.
Develop your own website with below functions:
Check the current state of the work item updated. You can get a work item information by REST API, and the check the value for System.State.
According to the value of System.State, to trigger related API or script.
B.
Login Power Automate and create a custom workflow. You can refer to this doc for more details.

Amazon SES persistent audit log

I am using Amazon SES to send transactional application emails. I want an audit log of every email sent by the system.
As an example, I might want to see a log of every email we sent to john.smith#example.com.
I followed the instructions for using Cloudwatch to log SES events. However, this only actually logs metrics, not data logs. So all I see in Cloudwatch is a graph of how many emails were sent at different times under the metrics tab. I can't search a log anywhere to find individual SES events.
I also looked into using Cloudtrail to log SES events, but Cloudtrail only logs management events. It does not log data events like emails being sent.
I have setup SNS notifications on all SES events (such as send or bounce). This is really useful, but does not achieve my aim of having a long term audit log.
As far as I can tell Amazon do not support the kind of logging I want to record. Maybe I could write events to our application database as we produce them, but it seems a shame to have to introduce my own custom logging system.
Does anyone know a way to have AWS store my SES data events?
Yes, Amazon doesn't have any easy to monitor you ask, an easier solution would be to add a Configuration set header and a unique message tag whenever any email is being sent to john.smith#example.com, In configuration set, you can enable Cloudwatch or preferred SNS Destination and create delivery dashboard using link below:
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/bouncecomplaintdashboard.html
This isn't the logs but It creates a nice excel file of email details which can be used for Audit purpose.
I opened a ticket with AWS about this, here is their response.
I understand that you wanted to know whether SES provides logs about events of an email that was accepted by SES for delivery in a searchable format. Please correct me if I’m wrong.
SES provides logs as notification[1] for each event(Delivery, Bounce, Complaint) to SNS and it doesn’t provide event logs in a consolidated manner which would be helpful for indexing according to email addresses and searching purpose. However, in SNS you can configure a variety of subscriber like(Email, SQS, Lambda, HTTP endpoint) where the logs in JSON format would be delivered. In the destination of SNS like Lambda and HTTP Endpoint or email, you can parse the JSON file and store in a suitable format which would be helpful for indexing and searching purpose.
If SQS is being used, each JSON log will be stored individually in the SQS queue for some time. You can periodically query the SQS endpoint and retrieve the logs and consolidate it to a single file and use it for analysis.
Apart from that, unfortunately SES doesn’t provide any other format of logs for an email it accepted for delivery.
Do let me know if you require any further assistance, I’ll be happy to help.
References:
[1]. https://docs.aws.amazon.com/ses/latest/DeveloperGuide/monitor-sending-using-notifications.html

Can I route my mailgun email to S3 bucket and save data there?

I have a requirement where I need to fetch email data and save somewhere. I can route it to my server and save the data there. Is there any feature where the email data can be routed to an S3 Bucket and I save the data there?
As I can see, you need a backend app that recursively fetch your emails using the Mailgun API formatted as json, then you can save these as text files on S3 service that can be queried later by another backend application.
It requires programming and a server infrastructure.
Regards,

Is Amazon provide any scheduler Api for scheduling the email

I'm using Amazon SES/SNS API of Amazon for sending email and getting notification.
Is Amazon provide any scheduler Api for scheduling the email for future? As i want to schedule my email by using Amazon API.
No, SES does not provide this functionality. You would need to do that yourself using a task scheduler such as the built-in windows or perhaps quartz.net if you need something more sophisticated
While they may not offer it directly in SES or SNS, they do offer similar functionality with SQS or SWF.
I made the service, huhumails.com
With HuhuMails, you can schedule your transactional emails with ease. It also makes sure emails are sent within your rate-limits. The service accepts date and timezone parameters to schedule your email at a specific time in the future.
I couldn't find anything on the market that's according to what I'm looking for and easy to use, so I created the service. I'm currently using it on my other production websites. Hopefully, it will be useful to others too.

How to Create email id for each user in Amazon Ec2?

I am running my application in amazon Ec2 with PHP.We are using S3 for storage images and files.Now I want to create the email id for each user those who are successfully register.
When the users send the mail from the another email id to this particular email id with attachment I need to get the files and upload to S3.
I read the SES document.But I didn't get any clue how to do this.Please let me know if you have any ideas.
It sounds to me like you want to parse incoming email for attachments, if so take a look at the imap functions and Mail_mimeDecode, I use a combination of both.