# s3-emails-to-mongo

> Take email objects stored on AWS S3 from AWS SES and store them into your local Mongo database. Removes objects from AWS S3 Bucket once indexed.

Latest version **2.3.4** (published 2018-02-02) · 0 weekly downloads

## Install

```sh
npm install s3-emails-to-mongo
pnpm add s3-emails-to-mongo
yarn add s3-emails-to-mongo
bun add s3-emails-to-mongo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.4 |
| Published | 2018-02-02 |
| First published | 2017-08-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Author | zachary hill |
| Maintainers | zhillb |
| Keywords | s3, aws, ses, mongo, emails |

## Links

- npm: https://www.npmjs.com/package/s3-emails-to-mongo
- Repository: https://github.com/zacharyhill/s3-emails-to-mongo
- Homepage: https://github.com/zacharyhill/s3-emails-to-mongo#readme
- Issues: https://github.com/zacharyhill/s3-emails-to-mongo/issues
- npm.io page: https://npm.io/package/s3-emails-to-mongo

## Dependencies (3)

- [util](https://npm.io/package/util.md) ^0.10.3
- [mongoose](https://npm.io/package/mongoose.md) ^4.13.9
- [s3-emails](https://npm.io/package/s3-emails.md) ^1.0.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 2.3.4 (latest) — 2018-02-02
- 2.3.3 — 2018-02-02
- 2.3.2 — 2018-02-02
- 2.3.1 — 2018-02-01
- 2.3.0 — 2018-02-01
- 2.2.4 — 2018-01-30
- 2.2.3 — 2018-01-21
- 2.2.2 — 2018-01-21
- 2.2.1 — 2018-01-21
- 2.2.0 — 2018-01-19
- 2.1.1 — 2018-01-15
- 2.1.0 — 2018-01-15
- 2.0.0 — 2018-01-15
- 1.0.11 — 2017-08-30
- 1.0.10 — 2017-08-30
- … 14 more at https://npm.io/package/s3-emails-to-mongo/versions

## README

## What this module does
This simple module takes mail objects stored on AWS S3 from AWS SES and indexes them into your mongo database.
You have to pass in the AWS Bucketname as described below and setup your AWS shared authentication and you should be good to go!

## How to use

In order to use this module, you must have AWS shared credential set up on your computer. You must pass in a configuration object to the configure method with a property called "Bucket" with your unique AWS bucket name. You can also choose to overwrite other options in the configuration (more on that below).

NOTE: This module automatically saves attachments in /data/uploads. This will be dynamic soon, but was added as saving the buffers to the database was causing issues.

```javascript
const getNewMessages = require('s3-emails-to-mongo');

getNewMessages.configure({
  Bucket: 'unique-aws-bucket',
});
```

### Consuming with a promise example:

```javascript
getNewMessages()
.then((messages) => {
	if (!messages.length) {
		console.log('no new messages!');
	}
	else {
		console.log('new messages added to DB!\n\n', messages);
	}
})
.catch((err) => {
	console.log(err);
});
```

### Callback Example

```javascript
getNewMessages((messages, err) => {
  if (!err) {
  	if (!messages.length) {
      console.log('no new messages!');
    }
    else {
      console.log('new messages added to DB!\n\n', messages);
    }
  } else {
    console.log('err', err);
  }
});
```


### Overwriting Configuration Options

This is the default configuration:

```javascript
{
    Bucket: '',
    DB: 'Mail',
    MailSchema: {
        headers: false,
        subject: true,
        from: true,
        to: true,
        cc: true,
        bcc: true,
        date: true,
        messageId: true,
        inReplyTo: true,
        'reply-to': true,
        references: false,
        html: false,
        text: true,
        textAsHtml: false,
        attachments: true,
        read: true,
    }
}
``` 

You can overwrite any of the above values as long as you give it the same data type it was originally set to. For example, if you wanted to save the `html` value but not save the `text` you could do this:

```javascript
getNewMessages.configure({
  Bucket: 'unique-aws-bucket',
  MailSchema: {
    html: true,
    text: false,
  }
});
```

---
_Source: https://npm.io/package/s3-emails-to-mongo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
