自創--簡單配置postfix+courier+squirrelmail+pam郵件服務器
发表于 : 2008-05-27 21:55
牢騷:從沒接觸過郵件服務器,我是一個菜菜鳥,因為公司郵件服務器要求比較復雜。經過寄個禮拜的努力和GOOGLE終于完成了這個巨作。NNND可憐我所有的休息時間都搭上去了,痛恨我那蹩腳的英語水平。痛恨ubuntu為什麽沒有完全的資料。所以本小姐為ubuntu貢獻一下。歡迎大家討論修改,指教
參考
http://wiki.ubuntu.org.cn/index.php?tit ... iant=zh-cn
http://wiki.ubuntu.org.cn/index.php?tit ... iant=zh-tw
http://wiki.ubuntu.org.cn/Ubuntu%E6%9C% ... 1.E5.99.A8
正文:
1.要求用戶使用web郵箱
2.用戶第一次登錄要求提示修改密碼
3.有發件自動回復功能
4.要求用戶賬號為別名
5.郵件過濾和防垃圾郵件,不用考慮,交給郵件防火牆搞定,幾W塊的郵件防火牆總得做點事情賽。軟件這方面暫時還不能和硬件比。
奇怪的要求吧,嘿嘿
軟件
1.平台ubuntu6.06
2.軟件postfix,(邮件传输代理(MTA)和SMTP服务器,這玩意功能很強也很靈活)courier(pop3/imap收件服務)squirrelmail(webmail).apache2.
3.考慮到很多因素所以使用本地認証,PAM認証而不使用mysql認証。有興趣的朋友可以嘗試下mysql認証
安裝
sudo apt-get update
sudo apt-get install apache2,php5,postfix.courier-imap.courier-imap,squirrelmail. (這些都是源裏面有的東西。ubuntu就是這點好)
設置
去到postfix目錄
cd /etc/postfix
備份配置文件
sudo cp main.cf mail.cfbak
修改配置文件
sudo vi main.cf
(main.cf下可以配置的参数有 300多个,绝大多数参数都是不需要配置的,因为默认值就很好。而作为最初的配置,我们更是只挑选其中的极少数几个先来配置一下。编辑这个文件,只列出需要修改或添加的行)我按照我的要求來修改
主機名test.mailserver.com 域名test.mailserver.com
代码
message_size_limit = 204800000 //規定郵件最大尺寸
myhostname = localhost // 找到此行,将等号后面的部分改写为主机名
myhostname = test.mailserver.com // 变为此状态,设置系统的主机名
myorigin = /etc/mailname //修改/etc/mailname補全成为E-mail地址“@”后面的部分,不過我沒有設置,因為我的主機名就是這個了
inet_interfaces = all // 接受来自所有网络的请求
mydestination = localhost, localhost.localdomain, , localhost // 找到此行,将行首的#去掉
mydestination = test.mailserver.com, localhost.localdomain, , localhost // 发给本地邮件的域名test.mailserver.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 // 找到此行,依照自己的内网情况修改。我假定你的本地网络是 192.168.1.0/24 并且将你的本地网络加入到{{{mynetworks}}}。
完成後它看起来应该像这样:
mynetworks = 127.0.0.0/8, 192.168.1.0/24
home_mailbox = Maildir/ //Maildir 是一个邮件池的格式,这种邮件格式不需要文件锁定来保证消息的完整性,因为邮件以一个特有的名字被保存在一个个单独的文件中。一个Maildir是一个包含3个叫做tmp, new和curd的子目录的目录(常常以Maildir命名)。这些子目录应该在同一个文件系统中。
另一个使用Maildir格式的邮箱的理由是Courier IMAP/POP3服务器只支持Maildir格式的邮箱。
在' mailbox_command = procmail -a "$EXTENSION" '那一行前面加上一个"#"将其注释掉。 如果沒有就不用去管了
好了postfix就改到這裏了,如果你們有別的需求要不去網上找,要不就man postfix
重啟下postfix
sudo /etc/init.d/postfix restart
測速postfix能否使用
telnet test.mailserver.com 25
Trying 127.0.1.1...
Connected totest.mailserver.com
Escape character is '^]'.
220 test.mailserver.com ESMTP Postfix (Ubuntu)
修改pam認証
因為使用pam認証,而且要求建立賬號時,自動建立用戶home目錄
cd /etc/pam.d
sudo cp common-session common-sessionbak
sudo vi common-session
看看是否有這句,沒有添加
session required pam_mkhomedir.so umask=0022 skel=/etc/skel
去到skel
cd /etc/skel
看看是否有一下文件,沒有手工添加
ls skel
Examples Maildir
ls skel/Maildir
cur new tmp
配置courier pop/imap
courier-imap我裝上去就哪裏都沒有改就可以了
測試
好了現在建立一個賬號測試一下 賬號TEST
sudo adduser test
Adding user `test'...
Adding new group `test' (1001).
Adding new user `test' (1001) with group `test'.
The home directory `/home/test' already exists. Not copying from `/etc/skel'
adduser: Warning: that home directory does not belong to the user you are currently creating
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
Full Name []: test
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/N] y
ok賬號建立了,去看看/home/test下是否有Maildir這個文件
在看看Maildir下是否有courierimapkeywords courierimapsubscribed courierimapuiddb cur new tmp 這些文件
測試一下IMAP
注意pop端口是110 imap是143
因為我用squirrelmail做webmail squirrelmail默認是支持imap的,網頁郵件還是用imap好,郵件放服務器比較安全
telnet test.mailserver.com 143
應該有如下顯示
Trying 127.0.1.1...
Connected to test.mailserver.com.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2004 Double Precision, Inc. See COPYING for distribution information.
在提示符下輸入
a login test test (注意第一個test是用戶ID 第二個是密碼,因為我密碼和ID一樣)
a OK LOGIN Ok.
a logout
不錯,可以使用了
這裏可以參考http://wiki.ubuntu.org.cn/index.php?title=PostfixBasicSetupHowto&variant=zh-cn
裏面詳細說明了pop3 和imap
設置squirrelmail
運行squirrelmail的配置程序
sudo squirrelmail-configure
當然也可以/usr/share/squirrelmail/config/conf.pl
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color on
S Save data
Q Quit
Command >>
輸入D--> 輸入courier 按R返回
在輸入1 因為我在WEBMAIL界面上顯示郵件地址為mailserver,com
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name : mailserver.com
2. Organization Logo : ../images/sm_logo.png
3. Org. Logo Width/Height : (308/111)
4. Organization Title : 按照你的需求輸入
5. Signout Page :
6. Top Frame : _top
7. Provider link : 按照你的需求輸入
8. Provider name : 按照你的需求輸入
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
輸入完成按R退回到主界面
選擇2
1. Domain :test.mailserver.com 輸入你的域名
2. Invert Time : false
3. Sendmail or SMTP : SMTP 選擇SMTP
A. Update IMAP Settings : localhost:143 (courier)
B. Update SMTP Settings : localhost:25
R Return to Main Menu
C Turn color on
S Save data
Q Quit
輸入後在退回主界面,8 選項是啟用插件。想啟用那個插件輸入插件前面的數字代碼即可
选择主菜单项10。即在命令提示符后输入数字“10”,进入语言设置子菜单,如图9-41所示。这里可将缺省语言(子菜单项1)改为“zh_CN”(中文),将缺省字符集(子菜单项2)改为“gb2312”
Language preferences
1. Default Language : zh_CN
2. Default Charset : utf8 我用UTF8大家可以使用 GB2312
3. Enable lossy encoding : false
R Return to Main Menu
C Turn color on
S Save data
Q Quit
按S保存 Q退出
这里要提一下squirrelmail汉化:
小松鼠邮件系统汉化
小松鼠本身支持很多语言,可下载相应的语言包。可到其主页去下载
www.squirrelmail.org
创建SquirrelMail别名
vi /etc/httpd/conf.d/squirrelmail.conf添加
alias /wemail /usr/share/squirrelmail
建立鏈接到/var/www
ln -s /usr/share/squirrelmail/ /var/www/webmail
在apache2中指定用戶訪問位置
sudo vi /etc/apache2/sites-enabled
ServerAdmin webmaster@localhost
ServerName webmail.mailserver.com
DocumentRoot /var/www/webmail
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
在你的DNS服務器中添加一條到test.mailserver.com的記錄
然後在你的電腦上輸入webmail.mailserver.com
就可以看到webmail 界面了
基本功能實現了輸入建立的賬號和密碼進去看看吧
可是對于我來說任務遠沒有完成
1.我服務器的域名和主機名稱是test.mailserver.com
要求用戶發送郵件到對方,對方顯示收件人地址欄地址為[email protected]
我搜索了squirrelmail的運行機制,在squirrelmail提交用戶郵件地址給postfix的時候,下手改掉地址(可能大家有更好的辦法,歡迎提供)
cd /usr/share/squirrelmail/class/deliver/
修改Deliver.class.php 文件,修改之前記得備份
sudo cp Deliver.class.php Deliver.class.phpbak
sudio vi Deliver.class.php
找到
$header[] = 'From: '. $rfc822_header->getAddr_s('from',",$rn ",true) . $rn;
修改為
$header[] = 'From: '.str_replace('test.mail','mail', $rfc822_header->getAddr_s('from',",$rn ",true) ). $rn;
因為我已經有了一個郵件別名系統
我只要在系統上設置給[email protected]的郵件到[email protected]即可
2.修改密碼
因為是用PAM認証
去squirrelmail官網去下載相應的插件。我下了支持PAM修改密碼的插件change_pass-2.7a-1.4.x.tar.gz 還有兼容插件compatibility-2.0.11-1.0.tar.gz
解壓縮到并復制到squirrelmail目錄
sudo tar -zxf change_pass-2.7a-1.4.x.tar.gz
sudo tar -zxf compatibility-2.0.11-1.0.tar.gz
sudo cp -r change_pass /usr/share/squirrelmail/plugins
sudo cp -r compatibility /usr/share/squirrelmail/plugins
查看change_pass的安裝說明文件INSTALL
要求安裝poppass這個插件
正好源裏面有
sudo apt-get install poppassd
poppassd要求開通106端口 106是很老的一些程序需求的INTERNET服務
UBUNTU默認是沒有打開這個端口的,需要安裝netkit-inetd
sudo apt-get install netkit-inetd
測試看是否OK
$ telnet localhost 106
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 poppassd v1.8.1 hello, who are you?
user <username>
200 Your password please.
pass <oldpassword>
200 Your new password please.
newpass <newpassword>
200 Password changed, thank-you.
quit
200 Bye.
Connection closed by foreign host.
啟用這個插件
sudo squirrelmail-configure
選擇8
找到compatibility。change_pass插件的數字代碼,輸入保存即可
現在登錄WEBMAIL 到選項裏面修改密碼看是否成功。
3.設置自動回復
去squirrelmail下載插件要選擇你對應認証方式的插件哦
我選擇的是支持PAM的
local_autorespond_forward-3.0-1.4.0.tar.gz
解壓,復制
sudo tar -zxf local_autorespond_forward-3.0-1.4.0.tar.gz
sudo cp -r local_autorespond_forward /usr/share/squirrelmail/plugin
查看安裝文件INSTALL 要求編譯這個文件
Go to the suid_binary directory and configure, compile and
install the suid backend. In many cases, you do not need
to manually specify any configuration options (except
possibly "--enable-auth=pam" and "--enable-webuser=USER"
(the latter only if your web server runs as some user
OTHER than "apache")), otherwise, please consult the README
file for a complete list of the available configuration
options.
$ cd local_autorespond_forward/vacation_binary
$ ./configure
$ make
$ su
# make install
If you do need to specify any configuration options, they
must be placed after the "./configure" command above.
Please note that it is important that you execute "make
install" as the root user.
4) Go back to the main local_autorespond_forward directory
$ cd ..
5) Copy config.sample.php to config.php, edit it and change
any settings as desired.
$ cp config.sample.php config.php
$ vi config.php
在看README文件
提示 編譯時要求加上apapche2執行用戶。(這裏大家可以根據自己的需求按照README的提示運作)
那麽我們可以查看apache2是那個用戶在執行
cat /etc/apache2/apache2.conf
找到User www-data
Group www-data
大家可以根據自己的修改
按照提示要求去到suid_backend目錄
cd suid_backend
sudo ./configure --enable-webuser[www-data] (這裏大家可以根據自己的需求按照README的提示添加參數)
編譯完成之後按照要求把local_autorespond_forward目錄下的config.sample.php文件改名為config.php
cd /usr/share/squirrelmail/plugins/local_autorespond_forward
sudo cp config.sample.php config.php
在運行
sudo squirrelmail-configure
選擇并啟用這個插件。
OK自動回復功能已經實現,發封郵件測試以下吧。
因為給用戶建立的初始密碼為password
設置第一次登錄提示更改密碼!
我直接修改的配置文件,不知道大家是否有更好的辦法
cd /usr/share/squirrelmail/plugins/chang_pass/
sudo cp options.php options.phpbak
sudo vi options.php
找到這一段
sqgetGlobalVar('plugin_change_pass', $plugin_change_pass, SQ_POST);
$messages = array();
if (isset($plugin_change_pass)) {
sqgetGlobalVar('cp_oldpass', $cp_oldpass, SQ_POST);
sqgetGlobalVar('cp_newpass', $cp_newpass, SQ_POST);
sqgetGlobalVar('cp_verify', $cp_verify, SQ_POST);
bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
$messages = change_pass_check();
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain('squirrelmail');
}
修改為
sqgetGlobalVar('plugin_change_pass', $plugin_change_pass, SQ_POST);
sqgetGlobalVar('mid',$mid);
$messages = array();
if (isset($plugin_change_pass)) {
sqgetGlobalVar('cp_oldpass', $cp_oldpass, SQ_POST);
sqgetGlobalVar('cp_newpass', $cp_newpass, SQ_POST);
sqgetGlobalVar('cp_verify', $cp_verify, SQ_POST);
bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
$messages = change_pass_check();
if ((!isset($_SESSION['secretkey'])) and ($mid==1))
{
Header('Location: /webmail/src/right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=INBOX');
}
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain('squirrelmail');
}
找到
bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
?>
<table width="100%" cellpadding="2" cellspacing="2" border="0">
<tr><td bgcolor="<?php echo $color[0] ?>">
<center><b><?php echo _("Change Password") ?></b></center>
</td></tr>
<tr><td>
<?php
if (count($messages)) {
foreach ($messages as $line) {
echo htmlspecialchars($line) . "<br>\n";
}
echo "</td></tr>\n";
echo "<tr><td>\n";
}bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
?>
<table width="100%" cellpadding="2" cellspacing="2" border="0">
<tr><td bgcolor="<?php echo $color[0] ?>">
<center><b><?php
if ($mid == 1 )
{
echo "You have to change your password !!!";
}
else
echo _("Change Password");
?></b></center>
</td></tr>
<tr><td>
修改為
保存退出
cd /usr/share/squirrelmail/src
sudo cp webmail.php webmail.phpbak
sudo vi webmail.php
找到這段
if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
$right_frame = '';
在它之前加上
if ($_SESSION['secretkey'] == 'password') {
$right_frame='/plugins/change_pass/options.php?mid=1';
保存
OK!現在 登錄webmail測試一下吧!
參考
http://wiki.ubuntu.org.cn/index.php?tit ... iant=zh-cn
http://wiki.ubuntu.org.cn/index.php?tit ... iant=zh-tw
http://wiki.ubuntu.org.cn/Ubuntu%E6%9C% ... 1.E5.99.A8
正文:
1.要求用戶使用web郵箱
2.用戶第一次登錄要求提示修改密碼
3.有發件自動回復功能
4.要求用戶賬號為別名
5.郵件過濾和防垃圾郵件,不用考慮,交給郵件防火牆搞定,幾W塊的郵件防火牆總得做點事情賽。軟件這方面暫時還不能和硬件比。
奇怪的要求吧,嘿嘿
軟件
1.平台ubuntu6.06
2.軟件postfix,(邮件传输代理(MTA)和SMTP服务器,這玩意功能很強也很靈活)courier(pop3/imap收件服務)squirrelmail(webmail).apache2.
3.考慮到很多因素所以使用本地認証,PAM認証而不使用mysql認証。有興趣的朋友可以嘗試下mysql認証
安裝
sudo apt-get update
sudo apt-get install apache2,php5,postfix.courier-imap.courier-imap,squirrelmail. (這些都是源裏面有的東西。ubuntu就是這點好)
設置
去到postfix目錄
cd /etc/postfix
備份配置文件
sudo cp main.cf mail.cfbak
修改配置文件
sudo vi main.cf
(main.cf下可以配置的参数有 300多个,绝大多数参数都是不需要配置的,因为默认值就很好。而作为最初的配置,我们更是只挑选其中的极少数几个先来配置一下。编辑这个文件,只列出需要修改或添加的行)我按照我的要求來修改
主機名test.mailserver.com 域名test.mailserver.com
代码
message_size_limit = 204800000 //規定郵件最大尺寸
myhostname = localhost // 找到此行,将等号后面的部分改写为主机名
myhostname = test.mailserver.com // 变为此状态,设置系统的主机名
myorigin = /etc/mailname //修改/etc/mailname補全成为E-mail地址“@”后面的部分,不過我沒有設置,因為我的主機名就是這個了
inet_interfaces = all // 接受来自所有网络的请求
mydestination = localhost, localhost.localdomain, , localhost // 找到此行,将行首的#去掉
mydestination = test.mailserver.com, localhost.localdomain, , localhost // 发给本地邮件的域名test.mailserver.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 // 找到此行,依照自己的内网情况修改。我假定你的本地网络是 192.168.1.0/24 并且将你的本地网络加入到{{{mynetworks}}}。
完成後它看起来应该像这样:
mynetworks = 127.0.0.0/8, 192.168.1.0/24
home_mailbox = Maildir/ //Maildir 是一个邮件池的格式,这种邮件格式不需要文件锁定来保证消息的完整性,因为邮件以一个特有的名字被保存在一个个单独的文件中。一个Maildir是一个包含3个叫做tmp, new和curd的子目录的目录(常常以Maildir命名)。这些子目录应该在同一个文件系统中。
另一个使用Maildir格式的邮箱的理由是Courier IMAP/POP3服务器只支持Maildir格式的邮箱。
在' mailbox_command = procmail -a "$EXTENSION" '那一行前面加上一个"#"将其注释掉。 如果沒有就不用去管了
好了postfix就改到這裏了,如果你們有別的需求要不去網上找,要不就man postfix
重啟下postfix
sudo /etc/init.d/postfix restart
測速postfix能否使用
telnet test.mailserver.com 25
Trying 127.0.1.1...
Connected totest.mailserver.com
Escape character is '^]'.
220 test.mailserver.com ESMTP Postfix (Ubuntu)
修改pam認証
因為使用pam認証,而且要求建立賬號時,自動建立用戶home目錄
cd /etc/pam.d
sudo cp common-session common-sessionbak
sudo vi common-session
看看是否有這句,沒有添加
session required pam_mkhomedir.so umask=0022 skel=/etc/skel
去到skel
cd /etc/skel
看看是否有一下文件,沒有手工添加
ls skel
Examples Maildir
ls skel/Maildir
cur new tmp
配置courier pop/imap
courier-imap我裝上去就哪裏都沒有改就可以了
測試
好了現在建立一個賬號測試一下 賬號TEST
sudo adduser test
Adding user `test'...
Adding new group `test' (1001).
Adding new user `test' (1001) with group `test'.
The home directory `/home/test' already exists. Not copying from `/etc/skel'
adduser: Warning: that home directory does not belong to the user you are currently creating
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
Full Name []: test
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/N] y
ok賬號建立了,去看看/home/test下是否有Maildir這個文件
在看看Maildir下是否有courierimapkeywords courierimapsubscribed courierimapuiddb cur new tmp 這些文件
測試一下IMAP
注意pop端口是110 imap是143
因為我用squirrelmail做webmail squirrelmail默認是支持imap的,網頁郵件還是用imap好,郵件放服務器比較安全
telnet test.mailserver.com 143
應該有如下顯示
Trying 127.0.1.1...
Connected to test.mailserver.com.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2004 Double Precision, Inc. See COPYING for distribution information.
在提示符下輸入
a login test test (注意第一個test是用戶ID 第二個是密碼,因為我密碼和ID一樣)
a OK LOGIN Ok.
a logout
不錯,可以使用了
這裏可以參考http://wiki.ubuntu.org.cn/index.php?title=PostfixBasicSetupHowto&variant=zh-cn
裏面詳細說明了pop3 和imap
設置squirrelmail
運行squirrelmail的配置程序
sudo squirrelmail-configure
當然也可以/usr/share/squirrelmail/config/conf.pl
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color on
S Save data
Q Quit
Command >>
輸入D--> 輸入courier 按R返回
在輸入1 因為我在WEBMAIL界面上顯示郵件地址為mailserver,com
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name : mailserver.com
2. Organization Logo : ../images/sm_logo.png
3. Org. Logo Width/Height : (308/111)
4. Organization Title : 按照你的需求輸入
5. Signout Page :
6. Top Frame : _top
7. Provider link : 按照你的需求輸入
8. Provider name : 按照你的需求輸入
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
輸入完成按R退回到主界面
選擇2
1. Domain :test.mailserver.com 輸入你的域名
2. Invert Time : false
3. Sendmail or SMTP : SMTP 選擇SMTP
A. Update IMAP Settings : localhost:143 (courier)
B. Update SMTP Settings : localhost:25
R Return to Main Menu
C Turn color on
S Save data
Q Quit
輸入後在退回主界面,8 選項是啟用插件。想啟用那個插件輸入插件前面的數字代碼即可
选择主菜单项10。即在命令提示符后输入数字“10”,进入语言设置子菜单,如图9-41所示。这里可将缺省语言(子菜单项1)改为“zh_CN”(中文),将缺省字符集(子菜单项2)改为“gb2312”
Language preferences
1. Default Language : zh_CN
2. Default Charset : utf8 我用UTF8大家可以使用 GB2312
3. Enable lossy encoding : false
R Return to Main Menu
C Turn color on
S Save data
Q Quit
按S保存 Q退出
这里要提一下squirrelmail汉化:
小松鼠邮件系统汉化
小松鼠本身支持很多语言,可下载相应的语言包。可到其主页去下载
www.squirrelmail.org
创建SquirrelMail别名
vi /etc/httpd/conf.d/squirrelmail.conf添加
alias /wemail /usr/share/squirrelmail
建立鏈接到/var/www
ln -s /usr/share/squirrelmail/ /var/www/webmail
在apache2中指定用戶訪問位置
sudo vi /etc/apache2/sites-enabled
ServerAdmin webmaster@localhost
ServerName webmail.mailserver.com
DocumentRoot /var/www/webmail
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
在你的DNS服務器中添加一條到test.mailserver.com的記錄
然後在你的電腦上輸入webmail.mailserver.com
就可以看到webmail 界面了
基本功能實現了輸入建立的賬號和密碼進去看看吧
可是對于我來說任務遠沒有完成
1.我服務器的域名和主機名稱是test.mailserver.com
要求用戶發送郵件到對方,對方顯示收件人地址欄地址為[email protected]
我搜索了squirrelmail的運行機制,在squirrelmail提交用戶郵件地址給postfix的時候,下手改掉地址(可能大家有更好的辦法,歡迎提供)
cd /usr/share/squirrelmail/class/deliver/
修改Deliver.class.php 文件,修改之前記得備份
sudo cp Deliver.class.php Deliver.class.phpbak
sudio vi Deliver.class.php
找到
$header[] = 'From: '. $rfc822_header->getAddr_s('from',",$rn ",true) . $rn;
修改為
$header[] = 'From: '.str_replace('test.mail','mail', $rfc822_header->getAddr_s('from',",$rn ",true) ). $rn;
因為我已經有了一個郵件別名系統
我只要在系統上設置給[email protected]的郵件到[email protected]即可
2.修改密碼
因為是用PAM認証
去squirrelmail官網去下載相應的插件。我下了支持PAM修改密碼的插件change_pass-2.7a-1.4.x.tar.gz 還有兼容插件compatibility-2.0.11-1.0.tar.gz
解壓縮到并復制到squirrelmail目錄
sudo tar -zxf change_pass-2.7a-1.4.x.tar.gz
sudo tar -zxf compatibility-2.0.11-1.0.tar.gz
sudo cp -r change_pass /usr/share/squirrelmail/plugins
sudo cp -r compatibility /usr/share/squirrelmail/plugins
查看change_pass的安裝說明文件INSTALL
要求安裝poppass這個插件
正好源裏面有
sudo apt-get install poppassd
poppassd要求開通106端口 106是很老的一些程序需求的INTERNET服務
UBUNTU默認是沒有打開這個端口的,需要安裝netkit-inetd
sudo apt-get install netkit-inetd
測試看是否OK
$ telnet localhost 106
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 poppassd v1.8.1 hello, who are you?
user <username>
200 Your password please.
pass <oldpassword>
200 Your new password please.
newpass <newpassword>
200 Password changed, thank-you.
quit
200 Bye.
Connection closed by foreign host.
啟用這個插件
sudo squirrelmail-configure
選擇8
找到compatibility。change_pass插件的數字代碼,輸入保存即可
現在登錄WEBMAIL 到選項裏面修改密碼看是否成功。
3.設置自動回復
去squirrelmail下載插件要選擇你對應認証方式的插件哦
我選擇的是支持PAM的
local_autorespond_forward-3.0-1.4.0.tar.gz
解壓,復制
sudo tar -zxf local_autorespond_forward-3.0-1.4.0.tar.gz
sudo cp -r local_autorespond_forward /usr/share/squirrelmail/plugin
查看安裝文件INSTALL 要求編譯這個文件
Go to the suid_binary directory and configure, compile and
install the suid backend. In many cases, you do not need
to manually specify any configuration options (except
possibly "--enable-auth=pam" and "--enable-webuser=USER"
(the latter only if your web server runs as some user
OTHER than "apache")), otherwise, please consult the README
file for a complete list of the available configuration
options.
$ cd local_autorespond_forward/vacation_binary
$ ./configure
$ make
$ su
# make install
If you do need to specify any configuration options, they
must be placed after the "./configure" command above.
Please note that it is important that you execute "make
install" as the root user.
4) Go back to the main local_autorespond_forward directory
$ cd ..
5) Copy config.sample.php to config.php, edit it and change
any settings as desired.
$ cp config.sample.php config.php
$ vi config.php
在看README文件
提示 編譯時要求加上apapche2執行用戶。(這裏大家可以根據自己的需求按照README的提示運作)
那麽我們可以查看apache2是那個用戶在執行
cat /etc/apache2/apache2.conf
找到User www-data
Group www-data
大家可以根據自己的修改
按照提示要求去到suid_backend目錄
cd suid_backend
sudo ./configure --enable-webuser[www-data] (這裏大家可以根據自己的需求按照README的提示添加參數)
編譯完成之後按照要求把local_autorespond_forward目錄下的config.sample.php文件改名為config.php
cd /usr/share/squirrelmail/plugins/local_autorespond_forward
sudo cp config.sample.php config.php
在運行
sudo squirrelmail-configure
選擇并啟用這個插件。
OK自動回復功能已經實現,發封郵件測試以下吧。
因為給用戶建立的初始密碼為password
設置第一次登錄提示更改密碼!
我直接修改的配置文件,不知道大家是否有更好的辦法
cd /usr/share/squirrelmail/plugins/chang_pass/
sudo cp options.php options.phpbak
sudo vi options.php
找到這一段
sqgetGlobalVar('plugin_change_pass', $plugin_change_pass, SQ_POST);
$messages = array();
if (isset($plugin_change_pass)) {
sqgetGlobalVar('cp_oldpass', $cp_oldpass, SQ_POST);
sqgetGlobalVar('cp_newpass', $cp_newpass, SQ_POST);
sqgetGlobalVar('cp_verify', $cp_verify, SQ_POST);
bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
$messages = change_pass_check();
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain('squirrelmail');
}
修改為
sqgetGlobalVar('plugin_change_pass', $plugin_change_pass, SQ_POST);
sqgetGlobalVar('mid',$mid);
$messages = array();
if (isset($plugin_change_pass)) {
sqgetGlobalVar('cp_oldpass', $cp_oldpass, SQ_POST);
sqgetGlobalVar('cp_newpass', $cp_newpass, SQ_POST);
sqgetGlobalVar('cp_verify', $cp_verify, SQ_POST);
bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
$messages = change_pass_check();
if ((!isset($_SESSION['secretkey'])) and ($mid==1))
{
Header('Location: /webmail/src/right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=INBOX');
}
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain('squirrelmail');
}
找到
bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
?>
<table width="100%" cellpadding="2" cellspacing="2" border="0">
<tr><td bgcolor="<?php echo $color[0] ?>">
<center><b><?php echo _("Change Password") ?></b></center>
</td></tr>
<tr><td>
<?php
if (count($messages)) {
foreach ($messages as $line) {
echo htmlspecialchars($line) . "<br>\n";
}
echo "</td></tr>\n";
echo "<tr><td>\n";
}bindtextdomain('change_pass', SM_PATH . 'plugins/change_pass/locale');
textdomain('change_pass');
?>
<table width="100%" cellpadding="2" cellspacing="2" border="0">
<tr><td bgcolor="<?php echo $color[0] ?>">
<center><b><?php
if ($mid == 1 )
{
echo "You have to change your password !!!";
}
else
echo _("Change Password");
?></b></center>
</td></tr>
<tr><td>
修改為
保存退出
cd /usr/share/squirrelmail/src
sudo cp webmail.php webmail.phpbak
sudo vi webmail.php
找到這段
if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
$right_frame = '';
在它之前加上
if ($_SESSION['secretkey'] == 'password') {
$right_frame='/plugins/change_pass/options.php?mid=1';
保存
OK!現在 登錄webmail測試一下吧!