Mailcap 是基于 RethinkDB 开发的一个邮件接收和归档服务器。
Mailcap 可以很好的在 RethinkDB 存储邮件:
Mailcap 是一个 SMTP 服务器,可以从任意的 MTA 中接收邮件,
邮件解析为 JSON 格式,易搜索,
文件附件使用 ReGrid(https://github.com/internalfx/rethinkdb-regrid) 存储,非常高效
安装
npm install -g mailcap
创建 config.js
mailcap bootstrap
编辑 config.js
module.exports = {
port: 2525, // Port server listens on
address: '', // Email address mail will be sent to
table: 'email', // RethinkDB table to store mail in
rethinkdb: {
host: 'localhost', // RethinkDB host address
db: 'test' // RethinkDB database name
},
regrid: {
bucketName: 'email' // ReGrid bucket name
}
}
启动服务器
mailcap start
存储格式
Mailcap 在配置表里面存储所有邮件,文件附件独立存储在 ReGrid。
邮件格式示例:
{
addresses: [
"fromAddress@example.com",
"toAddress@example.com"
],
attachments: [
{
"contentType": "image/jpeg",
"fileName": "swirly-ubuntu-wallpaper.jpg",
"length": 331469
}
],
cc: [ ],
createdAt: "Wed Mar 16 2016 03:28:55 GMT+00:00",
from: [
"fromAddress@example.com"
],
headers: {
content-type: 'multipart/mixed; boundary="----=_Part_87467_1755068617.1458098935181"',
date: "Wed, 16 Mar 2016 03:28:55 +0000 (UTC)",
from: "fromAddress <fromAddress@example.com>",
message-id: "<219358855.87471.1458098935216.JavaMail.asdfasdf@example.com>",
mime-version: "1.0",
received: [
"from localhost (localhost.localdomain [127.0.0.1]) by mail.example.com (Postfix) with ESMTP id ECC231C2B43 for <test@test.example.com>; Wed, 16 Mar 2016 03:29:00 +0000 (UTC)",
"from mail.example.com ([127.0.0.1]) by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id FM4FhPl1ZqLS for <test@test.example.com>; Wed, 16 Mar 2016 03:28:58 +0000 (UTC)",
"from localhost (localhost.localdomain [127.0.0.1]) by mail.example.com (Postfix) with ESMTP id 86B501C2B42 for <test@test.example.com>; Wed, 16 Mar 2016 03:28:57 +0000 (UTC)",
"from mail.example.com ([127.0.0.1]) by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3PFEkD1lm_1C for <test@test.example.com>; Wed, 16 Mar 2016 03:28:56 +0000 (UTC)",
"from mail.example.com (mail.example.com [xxx.xxx.xxx.xxx]) by mail.example.com (Postfix) with ESMTP id A9E291C2B43 for <test@test.example.com>; Wed, 16 Mar 2016 03:28:55 +0000 (UTC)"
],
subject: "This is a test email",
thread-index: "rX2hWYSOPicdVe5+pGD2LDwrQ2D/AA==",
thread-topic: "This is a test email",
to: "toAddress <toAddress@example.com>",
x-mailer: "Zimbra 8.6.0_GA_1191 (ZimbraWebClient - FF45 (Linux)/8.6.0_GA_1191)",
x-originating-ip: "[xxx.xxx.xxx.xxx]",
x-virus-scanned: "amavisd-new at mail.internalfx.com"
},
html: `<html><body>
<p>Hello,</p>
<p>Mailcap makes it easy to store emails in a RethinkDB database.</p>
<p>Thanks</p>
</body></html>`,
id: "d9e31972-6eee-46bd-b63f-acee4b2cd462",
messageId: "219358855.87471.1458098935216.JavaMail.asdfasdf@example.com",
subject: "This is a test email",
text: `Hello,
Mailcap makes it easy to store emails in a RethinkDB database.
Thanks
`,
to: [
"toAddress@example.com"
]
}
GitHub 地址:https://github.com/internalfx/mailcap
------------------
mailcap
A mail capture and archival server for RethinkDB.
Mailcap makes it easy to store emails in a RethinkDB database.
- Mailcap is an SMTP server so it can receive mail from any MTA.
- Emails are parsed into a JSON format that is easy to search.
- File attachments are saved efficiently using ReGrid
Getting Started
Install Mailcap
npm install -g mailcap
Create config.js
mailcap bootstrap
Edit config.js:
module.exports = {
port: 2525, // Port server listens on
address: '', // Email address mail will be sent to
table: 'email', // RethinkDB table to store mail in
rethinkdb: {
host: 'localhost', // RethinkDB host address
db: 'test' // RethinkDB database name
},
regrid: {
bucketName: 'email' // ReGrid bucket name
}
}
Start the server
mailcap start
Storage format
Mailcap stores all email in the configured table. File attachments are stored separately in ReGrid.
Email Format Example
{
addresses: [
"fromAddress@example.com",
"toAddress@example.com"
],
attachments: [
{
"contentType": "image/jpeg",
"fileName": "swirly-ubuntu-wallpaper.jpg",
"length": 331469
}
],
cc: [ ],
createdAt: "Wed Mar 16 2016 03:28:55 GMT+00:00",
from: [
"fromAddress@example.com"
],
headers: {
content-type: 'multipart/mixed; boundary="----=_Part_87467_1755068617.1458098935181"',
date: "Wed, 16 Mar 2016 03:28:55 +0000 (UTC)",
from: "fromAddress <fromAddress@example.com>",
message-id: "<219358855.87471.1458098935216.JavaMail.asdfasdf@example.com>",
mime-version: "1.0",
received: [
"from localhost (localhost.localdomain [127.0.0.1]) by mail.example.com (Postfix) with ESMTP id ECC231C2B43 for <test@test.example.com>; Wed, 16 Mar 2016 03:29:00 +0000 (UTC)",
"from mail.example.com ([127.0.0.1]) by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id FM4FhPl1ZqLS for <test@test.example.com>; Wed, 16 Mar 2016 03:28:58 +0000 (UTC)",
"from localhost (localhost.localdomain [127.0.0.1]) by mail.example.com (Postfix) with ESMTP id 86B501C2B42 for <test@test.example.com>; Wed, 16 Mar 2016 03:28:57 +0000 (UTC)",
"from mail.example.com ([127.0.0.1]) by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3PFEkD1lm_1C for <test@test.example.com>; Wed, 16 Mar 2016 03:28:56 +0000 (UTC)",
"from mail.example.com (mail.example.com [xxx.xxx.xxx.xxx]) by mail.example.com (Postfix) with ESMTP id A9E291C2B43 for <test@test.example.com>; Wed, 16 Mar 2016 03:28:55 +0000 (UTC)"
],
subject: "This is a test email",
thread-index: "rX2hWYSOPicdVe5+pGD2LDwrQ2D/AA==",
thread-topic: "This is a test email",
to: "toAddress <toAddress@example.com>",
x-mailer: "Zimbra 8.6.0_GA_1191 (ZimbraWebClient - FF45 (Linux)/8.6.0_GA_1191)",
x-originating-ip: "[xxx.xxx.xxx.xxx]",
x-virus-scanned: "amavisd-new at mail.internalfx.com"
},
html: `<html><body>
<p>Hello,</p>
<p>Mailcap makes it easy to store emails in a RethinkDB database.</p>
<p>Thanks</p>
</body></html>`,
id: "d9e31972-6eee-46bd-b63f-acee4b2cd462",
messageId: "219358855.87471.1458098935216.JavaMail.asdfasdf@example.com",
subject: "This is a test email",
text: `Hello,
Mailcap makes it easy to store emails in a RethinkDB database.
Thanks
`,
to: [
"toAddress@example.com"
]
}
from https://github.com/internalfx/mailcap
No comments:
Post a Comment