postfixÖÐÈçºÎ»ñµÃÒ»¸öÓʼþµÄÐÅ·âÐÅÏ¢£¨envelop header£©
ÓÐЩʱºò£¬ÎÒÃÇÐèÒªÓʼþµÄÐÅ·âÐÅÏ¢£¨envelop header£©£¬£¨Ò»¸öÓʼþµÄÐÅÌåÐÅÏ¢ºÜÈÝÒ×»ñµÃ£¬ÕâÀï²»ÐðÊö£©
ÏÂÃæ¼òµ¥µÄ˵˵Ôõôͨ¹ýpostfixµÄpipeÀ´»ñµÃÒ»¸öÓʼþµÄÐÅÍ·ÐÅÏ¢
´ó¸ÅʵÏÖ¹ý³ÌÈçÏ£º
ÉèÖÃcontent_filter£¬ÈÃpostfix°ÑÓʼþË͵½content_filterËùÖ¸ÏòµÄfilter³ÌÐò£¬Õâ¸öfilter³ÌÐòÓÉpostfix
µÄpipeÀ´µ÷Óã¬pipeµ÷ÓÃÕâ¸öfilter³ÌÐòʱºò£¬¿ÉÒÔ°ÑÐÅ·âÐÅÏ¢£¨mail from ºÍrcpt to ÐÅÏ¢£©´«µÝ¸øfilter
³ÌÐò
×ö·¨£º
(1) filter³ÌÐòµÄ±àд£¨ÕâÀïʹÓÃshell£©Õâ¸ö³ÌÐòÊÇ:/tmp/myfilter.sh
ÄÚÈÝÈçÏÂ
#!/bin/bash
cat > /tmp/messges_infor_txt #Õâ¾äµÄ×÷ÓþÍÊǰÑÓʼþµÄÐÅÌåÄÚÈÝдµ½/tmp/messges_infor_txtÎļþÖÐ
echo "$@" > /tmp/envelop_infor_txt
#Õâ¾äµÄ×÷ÓþÍÊǰÑÓʼþµÄ¡°ÐÅ·âÄÚÈÝ¡±Ð´µ½/tmp/envelop_infor_txtÎļþÖÐ
È»ºó·Ö±ð½¨Á¢2¸öÎļþ
touch /tmp/messges_infor_txt
touch /tmp/envelop_infor_txt
ÉèÖÃÏà¹ØµÄȨÏÞ
chmod 777 /tmp/myfilter.sh
chmod 777 /tmp/messges_infor_txt
chmod 777 /tmp/envelop_infor_txt
(ÕâÀïΪÁËÑÝʾʵÏÖfilter¹¦ÄÜ£¬ËùÒÔÉèÖÃΪ¡°world-writable¡±
´ó¼ÒÉèÖõÄʱºò£¬ÇëÉèÖúÃÏÞÖÆ£¬²»Òªworld-writable)
(2)ÉèÖÃcontent_filter
ÔÚ/etc/postfix/main.cfÖÐÉèÖÃ
content_filter = myfilter
(3)ÉèÖÃmaster.cf
ÔÚ/etc/postfix/master.cfÖмÓÈ룺
myfilter unix - n n - - pipe
flags=Rq user=filter argv=/tmp/myfilter.sh ${sender} -- ${recipient}
(4)ÖØÔØ
/etc/init.d/postfix reload