2013-03-14 24 views
2

幾年前,我在sendmail_path配置條目處遇到了一小段內聯bash代碼,這些代碼放到了php.ini文件中。內聯bash片斷的目的是將所有郵件重定向到一個文件。不幸的是,我失去了片段。我想用我的開發機器。有沒有人見過這樣的片段?將所有郵件重定向到文件

+0

人們可以只調用['三通(1)'](http://pubs.opengroup.org/onlinepubs/9699919799 /utilities/tee.html)? – eggyal 2013-03-14 20:41:17

+0

謝謝。這也適用。 – Joe 2013-03-14 21:10:05

回答

3
$ php -d sendmail_path="cat - >> /tmp/mailfile" -r "var_dump(mail('[email protected]','foo','bar'));" 
bool(true) 
$ cat /tmp/mailfile 
To: [email protected] 
Subject: foo 
X-PHP-Originating-Script: 1000:Command line code 


bar 
+0

謝謝。這也適用於:'sendmail_path ='tee -a /tmp/mail.out>/dev/null'' – Joe 2013-03-14 21:09:21

+0

我的確如此,但爲什麼複製標準輸入流到標準輸出流只是不必要的管道到dev/null ? – Wrikken 2013-03-14 21:12:08

+1

我不需要var_dump。這會工作嗎? sendmail_path =「cat - >>/tmp/mailfile」' – Joe 2013-03-14 21:13:53

0

當兩個電子郵件並行發送時,基於一個班輪的「貓」可能會造成競爭狀態。恕我直言,他們可能適合低負載簡單的est環境。

我會推薦基於解決方案的例如。在procmail上。 Procmail可以在傳遞到郵箱文件或傳遞給maildir時使用鎖定。

sendmail_path="/usr/bin/procmail -m /etc/procmailrcs/catch-mail.rc" 

/etc/procmailrcs/catch-mail.rc:

# deliver messages to /tmp/mailfile mailbox file 
DEFAULT=/tmp/mailfile 
相關問題