Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Client to read emails from Amazon S3 bucket

I've setup Amazon SES to forward all incoming emails to an S3 bucket. Now I'd like to read them with an email client. I've seen the javascript library http://emailjs.org/ which looks promising but I'd still have to create some kind of HTML webapp. What are my options to read emails in S3 from a web browser or a standalone desktop email client? The emails are saved in raw text MIME format in S3.

like image 312
TooSerious Avatar asked Jul 17 '16 01:07

TooSerious


1 Answers

There are some great JavaScript browser examples on AWS JS SDK page: Examples in the Browser. The "Basic Usage Example" shows you how to list objects in a bucket:

<div id="status"></div>
<ul id="objects"></ul>

<script type="text/javascript">
  var bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
  bucket.listObjects(function (err, data) {
    if (err) {
      document.getElementById('status').innerHTML =
        'Could not load objects from S3';
    } else {
      document.getElementById('status').innerHTML =
        'Loaded ' + data.Contents.length + ' items from S3';
      for (var i = 0; i < data.Contents.length; i++) {
        document.getElementById('objects').innerHTML +=
          '<li>' + data.Contents[i].Key + '</li>';
      }
    }
  });
</script>

The main thing you need to think about here is security, unless your bucket is public you will need some sort of backend service to provide the client with a signed key to perform the operations, take a look at getSignedUrl for this. One approach for building this service is to build a simple Lambda function that can verify authentication and provide signed keys.

like image 168
Karl Laurentius Roos Avatar answered Oct 19 '22 23:10

Karl Laurentius Roos