我现在(收邮件)的架构是:
mailin.io,收取邮件,然后解析成 JSON 。问题是, mailin 现在没有 retry ,也就是说,如果 webhook 挂了,你就收不到邮件了。所以我加了个 Redis 做 Queue ,另一个 Worker 做 webhook submission 。附件的话就直接上传到 S3 ,或者如果你像我一样自己跑 S3 的话,你可以上传到 S3 兼容的对象存储。
然后问题来了。我收到了邮件,收到了 JSON ,怎么把邮件存在数据库?
{ text: 'This is a test mailing',
  headers: 
   { date: 'Wed, 10 Feb 2016 20:16:22 -0800',
     to: 'test@something.com',
     from: 'me@jerrychen.me',
     subject: 'test Wed, 10 Feb 2016 20:16:22 -0800',
     'x-mailer': 'swaks v20130209.0 jetmore.org/john/code/swaks/',
     'mime-version': '1.0',
     'content-type': 'multipart/mixed; boundary="----=_MIME_BOUNDARY_000_18907"' },
  subject: 'test Wed, 10 Feb 2016 20:16:22 -0800',
  priority: 'normal',
  from: [ { address: 'me@jerrychen.me', name: '' } ],
  to: [ { address: 'test@something.com', name: '' } ],
  date: '2016-02-11T04:16:22.000Z',
  attachments: 
   [ { contentType: 'image/gif',
       fileName: '719.gif',
       contentDisposition: 'attachment',
       transferEncoding: 'base64',
       generatedFileName: '719.gif',
       contentId: 'dca3991c52568b0134a6cb117e1a7330@mailparser',
       checksum: '44859f23af61cacb375df1379051da25',
       length: 7298 } ],
  html: 'This is a test mailing',
  dkim: 'failed',
  spf: 'failed',
  spamScore: 0,
  language: 'english',
  cc: [],
  connection: 
   { id: '267e75b4-0003-40df-acec-59b7c5153bbb',
     remoteAddress: '127.0.0.1',
     clientHostname: '[127.0.0.1]',
     hostNameAppearsAs: 'jerrys-macbook-pro.local',
     envelope: { mailFrom: [Object], rcptTo: [Object] },
     user: false,
     transaction: 1,
     xClient: {},
     xForward: {},
     mailPath: '.tmp/267e75b4-0003-40df-acec-59b7c5153bbb' },
  envelopeFrom: { address: 'me@jerrychen.me', args: false },
  envelopeTo: [ { address: 'test@something.com', args: false } ] }
什么数据库架构了? RDBMS ? NoSQL ?求大家给意见
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.