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

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.

Related

AWS SES - Store email sent to`testing#my-domain.com` in S3, receive other emails to `me#my-domain.com` in iCloud?

Short Description
I am trying to figure out how to use AWS SES to receive email and store this in an S3 bucket, but only for a specific email address of a domain. The rest of the emails I would like to be handled by my email provider iCloud (or any other provider).
Why
I am working on a CDK Construct, and in order to test this construct I need to receive an email to a specific email address (testing#my-domain.com for example). I also need to read the contents of this email in order to complete the testing, however the domain I own is already setup to receive emails to other email addresses within that domain (contact#my-domain.com, and me#my-domain.com for example). Currently, this domain is registered through NameCheap (arbitrary DNS registrar) and the email client is setup through iCloud.
The Problem
The issue I am finding is that in order to receive email from AWS SES, I need to configure MX records for my domain on NameCheap to point to AWS SES. If I do this then I will no longer be able to receive emails from any other email addresses on my domain such as contact#my-domain.com or me#my-domain.com on iCloud (or any other email provider) as emails can only go to one server based upon the highest priority MX record.
In essence a pseudocode example of the logic I would like to have:
if email_address == 'testing#my-domain.com' then
save_to_s3_bucket()
else
default_send_to_icloud()
Investigated Solutions
Purchase second domain
One thing I could do, is apply a rule in iCloud that would forward all emails from the testing#my-domain.com email to go to any other address. The only way this would work is if I purchased a second domain and forwarded emails to an address on this domain. Here I could setup the MX records with no conflict as this domain would be used only for this purpose, and save to S3 bucket.
I don't like this approach because now I have to purchase a recurring fee of $12/year for a singular purpose of receiving an email for a test. This seems like an overkill solution for my problem.
Send email to S3 Bucket Endpoint
This is an imaginary solution (to the best of my knowledge), but wanted to show I have investigated this route. The idea would be if AWS S3 offered a service where they controlled a domain that anyone could send an email to, and then you could configure your S3 bucket to accept emails from some REGEX domain string and allow these to be saved to your bucket as a file. (I haven't fleshed out what the whole process is, but just giving rough concept)
This does not work as this is not a current offering from S3 (but would be pretty cool if they added it).
Forward to iCloud
The last option feels like a configuration nightmare, but the idea would be to configure AWS SES to receive all emails by setting the MX records of the domain to point there. Then we could apply rule-based filter to forward the emails that we aren't saving to S3 on to the iCloud server.
This approach has quite a few question marks, such as would the email appear to be sent from SES? How would I respond via iCloud to emails? Would need to investigate latency, dropped emails, etc. from SES.
I really don't want to do this as it feels like a nightmare of configuration. I have not done this though so please let me know if it is simpler than I might imagine.
These are the only solutions I have found thus far, are there any other solutions? I find it hard to believe I am the only person who has come across an issue like this, but googling for a solution like this is extremely difficult.
After some searching I found a solution by using a subdomain of my original domain. If I do this, then I can maintain the original MX records of my root domain and receive emails to my iCloud (or any other provider). Next I can add MX records to a subdomain, all emails will now be directed to AWS SES.
Type
Host
Value
Priority
TTL
MX
my-domain.com
mx04.mail.icloud.com
10
Automatic
MX
my-domain.com
mx07.mail.icloud.com
10
Automatic
MX
testing.my-domain.com
inbound-smtp.us-east-1.amazonaws.com
10
Automatic
The benefit of doing it this way is that subdomains are free in most (all?) DNS registrars.
AWS SES MX Configuration Docs
Now all emails from me#my-domain.com, contact#my-domain.com, etc will go to iCloud. All emails to anything#testing.my-domain.com, another#testing.my-domain.com, etc will go to AWS.

Download email attachment and upload S3 bucket AWS

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.

Why the file id, in telegram bot, not work after some days?

I am using telegram API and create php telegram bot. For sending video file with sendVideo method, use file_id like BAADBAADbwADhd7gCEpUooz4V5Q1Ag. But after some days this file_id not worked and I have to upload this video file again. What is the problem?
as you can read in this link:
Can I count on file_ids to be persistent?
For the moment, file_ids for your bot's outgoing files may be recycled
after several thousand files have been sent. This may be changed in
the future. Inbound file_ids can be treated as persistent.
so if you send a file from your server to telegram user (over the bot), the returned file_id can't be permanent. you can forward the file from user to bot and save file_id instead of that.
Telegram updated the FAQ
Can I count on file_ids to be persistent?
Yes, file_ids can be treated as persistent.

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,

Can user information be obtained from PID returned by devpay webservices or do I have to use s3 webservices for this?

I want to take a look at an S3 user's information (like # of buckets, bucket size, etc.). My question: can I use the PersistentIdentifier (PID) returned by Devpay (ActivateHostedProduct) to see any other information about the user other than the user's subscription status?
Looks like the PID is only good for telling you if a devpay customer is subscribed to your product or not.