Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to send email from a website hosted on s3

I have a website hosted on S3 on amazon web services. I want to receive emails on my gmail account from the visitors of my website if they wish to contact me. I'm confused with the steps for the setup as I tried working around with SES on amazon web service but am completely off tracK I believe.

Thanks.

like image 711
Ketan Avatar asked Feb 04 '16 06:02

Ketan


People also ask

Can you email an S3 bucket?

For S3 bucket, select the bucket that you created to store the emails. (Optional) For Object key prefix, you can enter an S3 prefix where you want to store the emails. If you leave this field blank, emails are stored at the root of the bucket.

Can S3 be used to host a website?

You can use Amazon S3 to host a static website. On a static website, individual webpages include static content. They might also contain client-side scripts. By contrast, a dynamic website relies on server-side processing, including server-side scripts, such as PHP, JSP, or ASP.NET.


3 Answers

S3 doesn't support any server-side code, such as PHP - so you can't use server-side logic to send an email.

There are two options:

  1. Implement a mailto: link that will cause the user to open their mail client when then click on it.
  2. Use a third-party mail service that supports a REST API, and implement that in Javascript. You can use something like SES, Sendgrid or Mailgun.

Each of these services can be called using Javascript. Implement your mail form page to make an API call to these services to deliver the comment to your inbox.

like image 64
Paddez Avatar answered Nov 08 '22 11:11

Paddez


You can use AWS Lambda with Amazon API Gateway to create a serverless backend and use Amazon Simple Email Service to send an e-mail. A good tutorial below:

Create Dynamic Contact Forms for S3 Static Websites Using AWS Lambda, Amazon API Gateway, and Amazon SES

like image 31
snowcold Avatar answered Nov 08 '22 10:11

snowcold


Late to the party, but as others have said you can setup a AWS Lambda function at an API Gateway to use AWS SES to send an email. You post your html form to it (or some other service you create on an actual server you control) and send an email via some Gmail SDK/API There's quite a few tutorials for this online.

You can also use a free third-party service like Formspree to create an html form that posts to their servers and they will send you an email to wherever you specify.

like image 34
unknownprotocol Avatar answered Nov 08 '22 10:11

unknownprotocol