<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Groove Labo &#187; postfix</title>
	<atom:link href="http://labo.opengroove.com/blog/category/postfix/feed/" rel="self" type="application/rss+xml" />
	<link>http://labo.opengroove.com/blog</link>
	<description>株式会社オープングルーヴの開発者のブログ</description>
	<lastBuildDate>Wed, 25 Aug 2010 06:55:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>メール受信で自動的にスクリプトを実行する</title>
		<link>http://labo.opengroove.com/blog/2009/08/07/%e3%83%a1%e3%83%bc%e3%83%ab%e5%8f%97%e4%bf%a1%e3%81%a7%e8%87%aa%e5%8b%95%e7%9a%84%e3%81%ab%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b/</link>
		<comments>http://labo.opengroove.com/blog/2009/08/07/%e3%83%a1%e3%83%bc%e3%83%ab%e5%8f%97%e4%bf%a1%e3%81%a7%e8%87%aa%e5%8b%95%e7%9a%84%e3%81%ab%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 15:06:44 +0000</pubDate>
		<dc:creator>sugimoto</dc:creator>
				<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://labo.opengroove.com/blog/?p=330</guid>
		<description><![CDATA[sugimotoです。


インターネット向けのシステムでは、ユーザーからのメールを受信して自動的に処理をすることがあります。



    メール投稿された記事をブログにアップする
    空メール送信による自動登録



postfix をメールサーバーにメール受信によるスクリプト実行の設定をする方法をメモしておきます。


1. postfixの設定


メール受信をするための細かい設定は省略しますが、スクリプト自動起動のため、alias の設定をします。



/etc/postfix/main.cf に以下の行を確認します。default で書いているので、そのままでいいですね。



alias_database = hash:/etc/aliases



受信するメールアドレスを正規表現で設定したい場合、正規表現アドレスを設定するファイルも追加しておきます。



alias_database = hash:/etc/aliases, regexp:/etc/aliases.regexp


2. aliasの設定


スクリプトを起動するメールアドレスを設定するために alias ファイルに設定を追加します。



groove@xxxxxx.xxx 宛てメールを受信したときに groove.php を実行する



[/etc/aliases]
groove: "&#124; /usr/bin/php /var/lib/groove.php"



open-xxxxx@xxxxxx.xxx 宛てメールを受信したときに open.php を実行する



この場合、正規表現設定用のファイル /etc/aliases.regexp に正規表現で設定します。



[/etc/aliases.regexp]
/^open-/: "&#124; /usr/bin/php /var/lib/open.php"



簡単です。。


3. postfixの設定


設定が終わったのでさっそくメールを送ると、以下のエラーで失敗してしまいました。



Command died with status 1: " /usr/bin/php
   /var/lib/groove.php". Command output: No log handling enabled -
   [...]]]></description>
			<content:encoded><![CDATA[<p>sugimotoです。</p>

<p>
インターネット向けのシステムでは、ユーザーからのメールを受信して自動的に処理をすることがあります。
</p>

<ul>
    <li>メール投稿された記事をブログにアップする</li>
    <li>空メール送信による自動登録</li>
</ul>

<p>
postfix をメールサーバーにメール受信によるスクリプト実行の設定をする方法をメモしておきます。
</p>

<h3>1. postfixの設定</h3>

<p>
メール受信をするための細かい設定は省略しますが、スクリプト自動起動のため、alias の設定をします。
</p>

<p>
/etc/postfix/main.cf に以下の行を確認します。default で書いているので、そのままでいいですね。
</p>

<pre>
alias_database = hash:/etc/aliases
</pre>

<p>
受信するメールアドレスを正規表現で設定したい場合、正規表現アドレスを設定するファイルも追加しておきます。
</p>

<pre>
alias_database = hash:/etc/aliases, regexp:/etc/aliases.regexp
</pre>

<h3>2. aliasの設定</h3>

<p>
スクリプトを起動するメールアドレスを設定するために alias ファイルに設定を追加します。
</p>

<p>
groove@xxxxxx.xxx 宛てメールを受信したときに groove.php を実行する
</p>

<pre>
[/etc/aliases]
groove: "| /usr/bin/php /var/lib/groove.php"
</pre>

<p>
open-xxxxx@xxxxxx.xxx 宛てメールを受信したときに open.php を実行する
</p>

<p>
この場合、正規表現設定用のファイル /etc/aliases.regexp に正規表現で設定します。
</p>

<pre>
[/etc/aliases.regexp]
/^open-/: "| /usr/bin/php /var/lib/open.php"
</pre>

<p>
簡単です。。
</p>

<h3>3. postfixの設定</h3>

<p>
設定が終わったのでさっそくメールを送ると、以下のエラーで失敗してしまいました。
</p>

<pre>
Command died with status 1: " /usr/bin/php
   /var/lib/groove.php". Command output: No log handling enabled -
   turning on stderr logging /usr/share/snmp/mibs/SNMP-COMMUNITY-MIB.txt:
   Permission denied /usr/share/snmp/mibs/NET-SNMP-TC.txt: Permission denied
   /usr/share/snmp/mibs/SNMPv2-TC.txt: Permission denied
   /usr/share/snmp/mibs/SNMPv2-SMI.txt: Permission denied
   /usr/share/snmp/mibs/SNMP-NOTIFICATION-MIB.txt: Permission denied
   /usr/share/snmp/mibs/SNMPv2-CONF.txt: Permission denied
   /usr/share/snmp/mibs/LM-SENSORS-MIB.txt: Permission denied
  ...中略・・・
   /usr/share/snmp/mibs/TRANSPORT-ADDRESS-MIB.txt: Permission denied
   /usr/share/snmp/mibs/IF-MIB.txt: Permission denied
   /usr/share/snmp/mibs/IPV6-UDP-MIB.txt: Permission denied Cannot find module
   (IP-MIB): At line 0 in (none) Cannot find module (IF-MIB): At line 0 in
   (none) Cannot find module (TCP-MIB): At line 0 in (none) Cannot find module
   (UDP-MIB): At line 0 in (none) Cannot find module (HOST-RESOURCES-MIB): At
   line 0 in (none) Cannot find module (SNMPv2-MIB): At line 0 in (none)
   Cannot find module (SNMPv2-SMI): At line 0 in (none) Cannot find module
   (NOTIFICATION-LOG-MIB): At line 0 in (none) Cannot find module
   (DISMAN-EVENT-MIB): At line 0 in (none) Cannot find mod
</pre>

<p>
しばらく途方にくれていましたが、Googleで検索したところ、 selinux がONになっていたことが原因ということ。
</p>

<pre>
[/etc/selinux/config]
SELINUX=disabled < < enforcingから変更
</pre>

<p>
以上、で成功しました。
</p>

<h3><span style="color: #999999;">zeera document search</span></h3>

<p><a title="zeera document searchで社内文書検索" href="http://search.opengroove.com/"><img class="alignnone" title="エンタープライズ検索 zeera document search" src="http://www.opengroove.com/images/search-banner.png" alt="エンタープライズ検索 zeera document search" width="224" height="50" /></a></p>

<p><span style="color: #999999;">zeera document searchで社内文書検索</span></p>
</pre>]]></content:encoded>
			<wfw:commentRss>http://labo.opengroove.com/blog/2009/08/07/%e3%83%a1%e3%83%bc%e3%83%ab%e5%8f%97%e4%bf%a1%e3%81%a7%e8%87%aa%e5%8b%95%e7%9a%84%e3%81%ab%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%82%92%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
