Add steps and functionality for using SES and SNS for email
BIN
docs/guides/images/received-email.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
docs/guides/images/ses-add-domain.png
Normal file
|
After Width: | Height: | Size: 452 KiB |
BIN
docs/guides/images/ses-verify.png
Normal file
|
After Width: | Height: | Size: 543 KiB |
BIN
docs/guides/images/sns-add-action-publish.png
Normal file
|
After Width: | Height: | Size: 312 KiB |
BIN
docs/guides/images/sns-add-actions-sns-menu.png
Normal file
|
After Width: | Height: | Size: 202 KiB |
BIN
docs/guides/images/sns-create-identity.png
Normal file
|
After Width: | Height: | Size: 207 KiB |
BIN
docs/guides/images/sns-create-ruleset.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
docs/guides/images/sns-create-subscription.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
docs/guides/images/sns-create-topic.png
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
docs/guides/images/sns-define-incoming-rule.png
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
docs/guides/images/sns-publish-menu.png
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
docs/guides/images/sns-topic-menu.png
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
docs/guides/images/testing-incoming-email.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
|
|
@ -1,9 +1,5 @@
|
|||
import { RedisDataSource } from '@omnivore/utils'
|
||||
import express, {
|
||||
Express,
|
||||
Request,
|
||||
Response,
|
||||
} from 'express'
|
||||
import express, { Express, Request, Response } from 'express'
|
||||
|
||||
import { env } from './env'
|
||||
import { getQueue } from './lib/queue'
|
||||
|
|
@ -16,6 +12,13 @@ console.log('Starting worker...')
|
|||
|
||||
const app: Express = express()
|
||||
|
||||
app.use(express.text({ limit: '50mb' }))
|
||||
// Force JSON for SNS
|
||||
app.use((req, res, next) => {
|
||||
req.headers['content-type'] = 'application/json'
|
||||
next()
|
||||
})
|
||||
|
||||
app.use(express.json({ limit: '50mb' }))
|
||||
app.use(express.urlencoded({ limit: '50mb', extended: true }))
|
||||
|
||||
|
|
@ -63,23 +66,38 @@ app.get('/_ah/health', (_req: Request, res: Response) => {
|
|||
app.post('/mail', addEmailEventToQueue)
|
||||
|
||||
app.post('/sns', async (req, res) => {
|
||||
const snsMessage = req.body as SnsMessage
|
||||
const bodyString = req.body as string
|
||||
const snsMessage = JSON.parse(bodyString) as SnsMessage
|
||||
|
||||
console.log(`Received SNS Message`, snsMessage)
|
||||
console.log(`Sns Topic ARN ${snsMessage['TopicArn']}`)
|
||||
|
||||
if (snsMessage.TopicArn != env.sns.snsArn) {
|
||||
console.log(`Topic ARN: ${snsMessage.TopicArn} Doesnt Match ${env.sns.snsArn}, failing...`)
|
||||
res.status(401).send()
|
||||
return
|
||||
}
|
||||
|
||||
if (snsMessage.Type == 'SubscriptionConfirmation') {
|
||||
console.log('Subscribing to topic')
|
||||
await axios.get(snsMessage.SubscribeURL)
|
||||
res.status(200).send()
|
||||
return
|
||||
}
|
||||
|
||||
if (snsMessage.Type == 'Received') {
|
||||
const mailContent = await simpleParser(snsMessage.content)
|
||||
const mail = convertToMailObject(mailContent)
|
||||
if (snsMessage.Type == 'Notification') {
|
||||
const message = JSON.parse(snsMessage.Message) as {
|
||||
notificationType: string
|
||||
content: string
|
||||
}
|
||||
if (message.notificationType != 'Received') {
|
||||
console.log('Not an email, failing...')
|
||||
res.status(400).send()
|
||||
}
|
||||
|
||||
const mailContent = await simpleParser(message.content)
|
||||
const mail = convertToMailObject(mailContent)
|
||||
console.log(mail)
|
||||
await (
|
||||
await queue
|
||||
).add('save-newsletter', mail, {
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ export type SnsMessage = {
|
|||
TopicArn: string
|
||||
SubscribeURL: string
|
||||
content: string
|
||||
Message: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,6 +294,43 @@ Setting up your own email server is a bit overkill for what we are trying to ach
|
|||
|
||||
#### Amazon Simple Email Service and SNS
|
||||
|
||||
Amazon Simple Email Service (SES) has options for email receiving. We can use this to add the email functionality to Omnivore-self hosted.
|
||||
|
||||
##### Step 1. Create Identity
|
||||
Create your identity using Amazon SES. This will be your domain.
|
||||
|
||||

|
||||
|
||||
##### Step 2. Verify the Domain using the CNAME Records.
|
||||

|
||||
|
||||
#### Step 3. Add the MX Record
|
||||
|
||||
See instructions on how to do that [here](https://docs.aws.amazon.com/ses/latest/dg/receiving-email-mx-record.html)
|
||||
|
||||
##### Step 4. Create Email-Receiving Ruleset
|
||||

|
||||

|
||||
|
||||
|
||||
##### Step 5. Create SNS Topic Target
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
|
||||
##### Step 6. Setup Subscription
|
||||
In SNS you must setup a subscription to your Omnivore Host.
|
||||

|
||||
|
||||
|
||||
##### Step 7. Test by sending email to Omnivore Email
|
||||

|
||||

|
||||

|
||||
|
||||
#### Zapier and other Webhook Services.
|
||||
|
||||
If you are just looking for a simple way to import emails into your Self Hosted Omnivore Account, you can use a service like Zapier to forward the email into the mail-proxy.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ REDIS_URL=redis://redis:6379/0
|
|||
#MAIL
|
||||
WATCHER_API_KEY=mail-api-key
|
||||
LOCAL_EMAIL_DOMAIN=domain.tld
|
||||
LOCAL_EMAIL_DOMAIN=domain.tld
|
||||
SNS_ARN=arn_of_sns #for if you use SES and SNS for Email.
|
||||
|
||||
# Web
|
||||
APP_ENV=prod
|
||||
|
|
|
|||