教你如何設置Postfixadmin的自動回復
Postfixadmin 是一個基于Web的 Postfix 郵件發(fā)送服務器的管理工具,郵箱的自動回復功能大家都用過,那如何在Postfix上實現(xiàn)呢,那就請Postfixadmin管理工具幫忙吧,請看下文。
1. 創(chuàng)建一個本地帳戶
創(chuàng)建一個"vacation"的本地帳戶,并且"vacation"不容許登陸。不要使用"nobody",也不能使用"root"和"postfix"等。
#/etc/passwd
vacation:*:65501:65501::0:0:Virtual Vacation:/nonexistent:/sbin/nologin
#/etc/group
vacation:*:65501:
2. 為自動回復創(chuàng)建數(shù)據(jù)表
USE postfix;
#
# Table structure for table vacation
#
CREATE TABLE vacation (
email varchar(255) NOT NULL default '',
subject varchar(255) NOT NULL default '',
body text NOT NULL,
cache text NOT NULL,
domain varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(4) NOT NULL default '1',
PRIMARY KEY (email),
KEY email (email)
) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Vacation';
3. 創(chuàng)建一個目錄
創(chuàng)建一個目錄,例如/var/spool/vacation,它只容許"vacation"用戶訪問
vacation.pl腳本及其日志文件等將放在這里。
4. 復制文件
將$postfixadmin-2.1.0/VIRTUAL_VACATION/vacation.pl文件拷貝到剛才創(chuàng)建的文
件夾中
$ cp vacation.pl ;/vacation.pl
$ chown -R vacation:vacation ;
然后你將會看到:
ls -al ;/
-rwx------ 1 vacation vacation 3356 Dec 21 00:00 vacation.pl*
#p#
5. 修改文件
為了讓 vacation.pl 能夠執(zhí)行所有郵件都回復這一特性,下面修改其內(nèi)容:
將if (do_cache ($email, $orig_from)) { return; } 這句注銷掉即可。
6. 開始對系統(tǒng)進行設置
在master.cf中定義transport 的類型:
#/etc/postfix/master.cf:
vacation unix - n n - - pipe
flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}#
在mail.cf 中設定一個 transport maps file
下面舉A/B兩種方法
A.哈希數(shù)據(jù)庫
#/etc/postfix/main.cf:
transport_maps = hash:/etc/postfix/transport
然后添加在/etc/postfix/transport 文件中添加一條新的解析記錄
#/etc/postfix/transport
autoreply.yourdomain.com vacation
注意:"autoreply.yourdomain.com"此處與$postfixadmin-2.1.0/config.inc.php文件中的$CONF['vacation_domain']的參數(shù)相同
"vacation"要與master.cf 中的 "vacation" 相同
執(zhí)行 "postmap /etc/postfix/transport" 去創(chuàng)建一個哈希數(shù)據(jù)庫
執(zhí)行 "postfix reload" 完成配置
B.mysql數(shù)據(jù)庫
#/etc/postfix/main.cf:
transport_maps = mysql:/etc/postfix/mysql/mysql_virtual_transport_maps.cf
其中mysql_virtual_transport_maps.cf的內(nèi)容如下
user = postfix
password = postfix
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = transport
where_field = domain
additional_conditions = and backupmx = '0' and active = '1'
然后添加使用postfix admin 創(chuàng)建新域"autoreply.com",在Transport段中添加"vacation"
執(zhí)行 "postmap /etc/postfix/transport" 去創(chuàng)建一個哈希數(shù)據(jù)庫
執(zhí)行 "postfix reload" 完成配置
看完全文大家有什么感想,有什么不懂的就給我留言,其實挺簡單的!
【編輯推薦】