自动存储电子邮件附件文件

发布于 2024-12-07 05:06:18 字数 482 浏览 0 评论 0原文

最近,我的老板要求我创建...一些我发现在没有人工干预的情况下几乎不可能的事情,

事情是,让我们的用户通过电子邮件发送包含一些数据的 xml,但我的老板希望

  1. 将附件存储在特定文件夹上的特定文件夹 每当收到带有附件的新电子邮件时,服务器
  2. 都会验证该电子邮件中是否有附件 这是正确的,这意味着它的 xml 结构正如我们所要求的那样 它并存储了所有数据
  3. 一些 xml 文件数据存储在数据库中(文件名、文件 路径、主 ID)以便在显示的小应用程序上搜索它 或者

我的主要问题是,让这个过程不断检查新收到的邮件、检索附件、检查并存储它,我不知道是否可能, 从哪里开始。这一次,电子邮件服务器需要具有某种可编程性进程,但看起来负责我们邮件服务器的人仍然不知道是否存在类似的东西。

任何人都可以告诉我从哪里开始?

我建议我们在我们的主页上有一个上传选项,我们将会有它,但他们真的想要电子邮件选项,并且所有过程都是自动化的

I was recently asked by my boss to create... something i find nearly impossible without human intervention

The thing is, to have our users send a xml with some data via email, but my boss wants it to

  1. That the attached file be stored on a specific folder on a specific
    server whenever a new email arrives with the attachment
  2. The process will verify that there's a attached file on the email
    and thats its correct, meaning that its xml structure is as we asked
    it and has all the data stored on it
  3. Some of the xml file data be stored on a database (filename, file
    path, main id) for it to be searched on a little app which displays
    the xml data and so be able to download a copy of the file

My main problem is, having this process that keeps on cheking new received mails, retrieves the attachments, checks it and store it, i don't know if its possible, or where to start. For once, the email server needs to have some kind of programability processes, but still, looks like the one in charge of our mail server doesn't have any idea if there's something like that.

Any one can give me an idea on where to start with this?

I suggested we had a upload option on our main webpage, and we will have it, but they really want the email option and that all the process its automated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失与倦" 2024-12-14 05:06:18

有几种方法可以做到这一点。我首先考虑通过 IMAP 或 POP 以编程方式检索电子邮件。这似乎是对您来说摩擦最少的方法。您的电子邮件服务器的负责人可以为您设置一个帐户,所有邮件都转发到该帐户中。

或者,您可以编写一些内容将所有电子邮件转发到另一个邮件服务器,并使用它将电子邮件通过管道传输到脚本中,或者将其转发到诸如 cloudmailin.com(也可以将附件发送到 S3),以便您可以通过编程方式获取消息。

收到消息后,您只需解析附件并将其复制到您需要的文件夹中。

There are a couple of ways to do this. I would start by looking into programatically retrieving the emails via IMAP or POP. This seems like the approach with the least amount of friction involved for you. The person in charge of your email server could just set you up an account that all the messages are forwarded into.

Alternatively you can write something to forward all of the emails to another mail server and use that to pipe the emails into a script or have it forward to a service like cloudmailin.com (which can also send the attachments to S3) so that you can obtain the message programatically.

Once you have the message you then just need to parse out the attachment and copy it over to the folder that you need.

浪荡不羁 2024-12-14 05:06:18

如果您有邮件服务器上的 shell 访问权限,则可以使用 Procmail。它(或者您的 .forward 或等效内容中的任何内容)将随着每个传入消息作为其标准输入而被触发。如果并非所有传入消息都令人感兴趣,那么将 Procmail 作为包装器肯定是有意义的。无论如何,验证和分离传入附件的任务“只是一个简单的编程问题”,但我希望这至少足以让您开始。

:0B
* ^Content-type: application/x-perimental-xml or what have you
| validate-and-store-and-extract-some-data-to-sql

你当然可以把它做得比这更复杂(而且很可能你必须这样做),但这个基本的配方并不是很复杂。

...你的“几乎不可能”的描述听起来就像你在 Windows 上(哎呀,抱歉,无法抗拒),但也许你的邮件服务器仍然是 Unix 服务器。

If you have shell access on the mail server, you could use Procmail. It (or whatever you have in your .forward or equivalent) will be fired with each incoming message as its standard input. If not all incoming messages are interesting, having Procmail as a wrapper would certainly make sense. Anyway, the task to validate and detach the incoming attachment is then "just a simple matter of programming", but I hope this should at least be enough to get you started.

:0B
* ^Content-type: application/x-perimental-xml or what have you
| validate-and-store-and-extract-some-data-to-sql

You could certainly make it more elaborate than this (and most likely you will have to) but this essential recipe is not very complicated.

... Your "almost impossible" characterization sounds like you're on Windows (oops, sorry, couldn't resist) but perhaps your mail server is a Unix server nevertheless.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文