LoginSignup
24
26

More than 5 years have passed since last update.

空メール送信でプログラム起動をpostfixで実現する

Posted at

世の中にクソほどあふれていそうなTipsだが、教える必要に迫られたのでシンプルにまとめた。

postfixのインストール

$ sudo yum install postfix
$ sudo vi /etc/postfix/main.cf

postfixの設定

/etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

# 下記はセキュリティ系の設定
smtpd_banner = $myhostname ESMTP unknown
disable_vrfy_command = yes
smtpd_helo_required = yes

sendmailからpostfixに切り替え

$ sudo service sendmail stop
$ sudo chkconfig sendmail off
$ sudo service postfix stop
$ sudo chkconfig postfix on
$ sudo alternatives --config mta

2 プログラムがあり 'mta' を提供します。

  選択       コマンド
-----------------------------------------------
 + 1           /usr/sbin/sendmail.sendmail
*  2           /usr/sbin/sendmail.postfix

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します: 「2」を入力

空メール受信のアカウント作成

blank@example.com で受信する。

$ sudo useradd -s /sbin/nologin -M blank
$ sudo vi /etc/aliases

トリガーの設定

blank:"|/usr/bin/php /tmp/hoge.php"
$ sudo postalias /etc/aliases
24
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
26