安装 Usermin 工具的 Vacation 模块,使用户可以通过 web 方式设置 Vacation。
Vacation 可以自动回复邮件,下载源代码后编译安装。然后将二进制程序复制到 /usr/bin 目录。
Vacation 需要和 Sendmail 交互,因此需要修改以下配置:
然后,修改用户目录的 .forward 文件
\user001 "|vacation -a daniel.liao user001"
vacation 指定的用户名一定要是系统中存在的用户,-a 指定别名。
然后在用户目录中创建 .vacation.msg 文件,文件为 relpy 的邮件内容。运行命令 vacation -I(Initialize the .vacation.db file and start vacation)
默认情况下,发送过 vacation mail 的地址记录在在 .vacation.db 中,7 天内不会重复发送。
Usermin 默认包含 vacation 模块,仅需要启用该模块。
通过Webmin界面安装http://www.gifford.co.uk/webmin/ vacation 包。
Webmin中启用 Usermin 模块: Webmin →
Usermin 默认的首页中包含界面信息和默认的发送模板,界面信息在 /usr/libexec/usermin/vacation/lang/en 文件中设置。
index_title=Vacation Auto-Reply index_desc=Set your vacation auto-reply message here.<BR>It's usually helpful message. subject_desc=Subject: subject_text=Re: $SUBJECT from_desc=From: body_desc=Message Body: body_text=I will be out of the office until next week. I will read your message regarding "$SUBJECT" when I return. vacation_enable=Enable Vacation vacation_disable=Disable Vacation vacation_update=Update Vacation Message
修改 /usr/libexec/usermin/vacation/vacation-lib.pl 文件:
sub get_from { >>> $alias = `./getusername.sh $remote_user | tr -d '\n'`; <<< $from = $remote_user.'@'.$hostname; >>> $from = $alias.'@'."wuerth-phoenix.com"; } sub start_vacation { >>> $alias = `./getusername.sh $remote_user | tr -d '\n'`; if (-e $forward_file) { #backup existing .forward file and add vacation pipe. copy("$forward_file","$forward_save_file"); open(FORWARD, ">>$forward_file"); print FORWARD "\\$remote_user\n"; <<< print FORWARD "\"|$config{'vacation_path'} $remote_user\""; >>> print FORWARD "\"|$config{'vacation_path'} -j -a $alias $remote_user\""; close(FORWARD); } else { open(FORWARD, ">$forward_file"); print FORWARD "\\$remote_user\n"; <<< print FORWARD "\"|$config{'vacation_path'} $remote_user\""; >>> print FORWARD "\"|$config{'vacation_path'} -j -a $alias $remote_user\""; close(FORWARD); } }
上面脚本调用了 getusername.sh 用来获取用户的 Full Name。
#! /bin/bash ypcat passwd | grep $1 | awk -F: '{ print $5 }' | tr [:upper:] [:lower:] \ | tr -s ' ' '.'
Comments
There are currently no comments
New Comment