如何在linux中无痛地接收邮件并将其提供给Rails? [英] How do I painlessly receive mail in linux and feed it to Rails?

查看:155
本文介绍了如何在linux中无痛地接收邮件并将其提供给Rails?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索postfix howto的Google搜索引擎,但是我仍然无法弄清楚我如何设法在linux-server上接收电子邮件(更具体的是Ubuntu)。



所有我需要的是一个全部的邮箱,它会收到所有的电子邮件,并将其提供给红宝石脚本(当然,它会传递给Rails)。我能够在之前设置发送电子邮件的后缀,我不得不说 - 这根本不痛苦,除了实际安装之外,我几乎没有做任何事。



<你可以建议一个很好的howto或一个配方,还是一个可以解决问题的替代易于设置的邮件服务器?

解决方案

这个答案有两个部分,Norman Ramsey的回答涵盖了第二部分:将电子邮件传递给要处理的脚本。第一部分是配置Postfix以接收电子邮件。因为你需要一个全部的你可以把这样的东西在/ etc / postfix / aliases

  @ yourdomain.com localuser 

而'localuser'是系统上具有

$ b的帐户名称
$ b

/home/localuser/.forward



其中包含命令(参见诺曼的回应)。或者,您可以将其全部保留在Postfix中



/ etc / postfix / aliases:



@ yourdomain.com | / path / to / your / script



这将发送所有发送到@ yourdomain.com的电子邮件,并发送到您的脚本进行处理。请记住,脚本将作为postfix用户执行,因此您需要确保您的环境设置正确(例如,您不依赖于您的普通用户帐户具体的特定$ PATH)。后缀用户可能具有非常基本的环境(例如,甚至可能在$ PATH中没有/ usr / local / bin)


I've been googling all night for postfix howto's, but still I couldn't figure out how do I manage to receive email on linux-server (being more specific - Ubuntu).

All I need is a catch-all mailbox which gets all emails and feeds them to the ruby script (which then passes it to Rails, of course). I was able to set-up postfix for sending emails a while ago and I have to say - it wasn't painful at all, I did almost nothing besides actually installing it.

Could you suggest a good howto, or a recipe, or an alternative easy-to-setup mail-server that could solve the issue?

解决方案

There are two parts to this answer, Norman Ramsey's answer covers the 2nd part: handing off the email to a script to be processed. The first part is configuring Postfix to receive the email. Since you need a catch-all you can put something like this in /etc/postfix/aliases

@yourdomain.com localuser

And 'localuser' is the name of the account on your system which has a

/home/localuser/.forward

which contains the command (see Norman's response). Or, you could keep it all in Postfix

/etc/postfix/aliases:

@yourdomain.com |/path/to/your/script

This will send all email that is sent to @yourdomain.com and sends it to your script for processing. Keep in mind that the script will be executed as the postfix user, so you will need to make sure your environment is setup appropriately (for instance you are not relying on a specific $PATH that your normal user account has). The postfix user likely has a very basic environment (e.g. might not even have /usr/local/bin in their $PATH)

这篇关于如何在linux中无痛地接收邮件并将其提供给Rails?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆