配置postfix+dovecot+mysql+postfixadmin+squirrelmail 邮件系统笔记
最近想搭建一個完整的mailserver,查了很多資料,一直沒有成功,網上大部分資料是在redhat系列的操作系統上的,而且很多都是采用rpm包。
我現在的系統是suse Linux有許多包已經安裝,如果安裝新的包,會產生很多沖突問題,卸載又遇到很多依賴問題,所以決定全部采用源代碼的方法來安裝。為了以后查詢方便,將配置過程和資料整理如下。
下面開始正式安裝,這次安裝,首先是根據http://www.redlinux.org/read.php?tid-481.html
貼子中的安裝的,開始不明白這些軟件的用途,亂裝一氣,然后又參照橡皮樹老師的網絡視頻配置,最終排錯過程中不得不細細考究了一下這些軟件的作用,為了簡單,最后基本上安裝橡皮樹老師的配合來的,唯一不同的地方是,我的安裝基本上是采用源代碼方式,而且配置文件全部是自定義的,下面有些軟件的安裝對于本郵件系統并沒有必要,但是考慮以后的功能增加,就先裝上。
?
zlib的安裝
zlib是一個傳輸的壓縮支持庫
zlib
./configure -prefix=/opt/mailserver/zlib -64
curl 的安裝
curl是一個提供http,ftp,imap等協議的命令行模塊。
下面是編譯參數
./configure
-prefix=/opt/mailserver/curl
-with-ssl=/opt/mailserver/openssl
--with-zlib=/opt/mailserver/zlib
Libssh2的安裝
本打算把libssh的支持也編譯進去,但是編譯libssh失敗,提示openssh的庫文件不對。
Libssh build with openssl error
`OPENSSL_cpuid_setup' can not be used when making a shared object;
換了幾個版本,故障依舊,因此就沒有加入libssh支持。
下面是編譯參數
./configure
--prefix=/opt/mailserver/curl
--with-zlib=/opt/mailserver/zlib
--with-ssl=/opt/mailserver/openssl
--with-libssh2=/opt/mailserver/libssh2
?
?
?
Libssh與libssh2的區別如下
item ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? libssh2 ? ? ? ? ? ? ? ? ? ? ? ? ? ?? libssh
Licence?????????????????????????? Modified BSD?????????????????????????? LGPL
Non-blocking API ? ? ? ? ? ? ? everything ? ? ? ? ? ? ? ? ? ? ? ???? parts
Limits on?????????????????????????? >4GB files yes??????????????????????? no
Server-side?????????????????????????? no????????????????????????????????????? yes
Stable API???????????????????????????? yes???????????????????????????????????? no
C compatibility?????????????????????? C89????????????????????????? ? ?????? C99
strict namespace?????????????????? yes?????????????????????????? ?? ?????? no
man pages for all functions ?? yes?????????????????????????? ? ? ?? ? no
SSHv1 support??????????????????????? no???????????????????????????????? ? ? yes
Build concept ? ? ? ? ? ? ? ? ? ? ? ??? Autotools ? ? ? ? ? ? ? ? ?? ???? CMake
?
?
安裝:Berkeley-db
這是一個數據庫軟件,據說是Cyrus-SASL and Cyrus-IMAP所必需的數據庫支持。
tar xzvf db-4.7.25.tar.gz
cd db-4.7.25
../dist/configure --prefix=/opt/mailserver/BerkeleyDB
make
make install
下面的步驟,主要是對讓系統找到庫文件和頭文件,對于不同的系統,可能會有不同的操作。
如果不鏈接,下面裝openldap就會報錯,提示庫文件不匹配。
當然,本次郵件系統并沒有用到這個功能。
ln -s /opt/mailserver/ BerkeleyDB/include/* /usr/include/
mv /lib64/libdb-4.so /lib64/libdb-4.so.old
ln -s /opt/mailserver/ BerkeleyDB/lib/* /lib64/
安裝:Openldap
這個軟件功能還不是很了解,只是看到postfix支持此功能就順便裝上了。
tar xzvf openldap-stable-20100219.tgz
cd openldap-2.4.21
./configure --prefix=/opt/mailserver/openldap
make
make install
安裝:Openssl
這個在postfix也是支持的,但是考慮到配置的復雜性,暫時沒有在郵件系統中使用,在imap的軟件安裝中,也要用到openssl庫,而且經常會報openssl庫的錯誤,一般情況,分別編譯靜態庫和動態庫,或者編譯含 -fPIC 選項的靜態庫,可能會解決問題。
./config shared 生成動態庫
./config -fPIC 生成靜態庫加-fPIC選項
./config --prefix=/opt/mailserver/openssl
make
make install
下面再重新編譯一次,生成動態庫,默認的沒有生成動態庫,這個在php編譯的時候會需要。
./config --prefix=/opt/mailserver/openssl shared
make
make install
我用這個庫在安裝最新版本的dovecot時,提示靜態庫需要用-fPIC來編譯,本次就沒有測試了,因為最終采用的是穩定版本的dovecot。
下面的步驟,主要是對讓系統找到庫文件和頭文件,對于不同的系統,可能會有不同的操作。ln -s /opt/mailserver/openssl/include/openssl /usr/include/openssl
ln -s /opt/mailserver/openssl/lib/* /lib64
安裝:mysql
mysql采用的是相應平臺二進制包的形式安裝,如果采用源代碼安裝難度要大一點,因為我曾經失敗了幾次,最終下載了一個二進制包,步驟基本上再INSTALL文件中有,需要的額外操作時如何修改配置文件的位置問題,而且Mysql配置文件修改后,其他配合的軟件參數也有許多地方需要修改。
groupadd mysql
useradd -g mysql mysql
cd /opt/mailserver
tar xzvf mysql-5.1.45-linux-x86_64-glibc23.tar.gz
mv mysql-5.1.45-linux-x86_64-glibc23 mysql
cd mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
bin/mysqld_safe --user=mysql & //測試是否正確啟動
bin/mysqladmin -u root password 123 //給root用戶加密碼
cp support-files/mysql.server /etc/init.d/mailserver.mysql //增加自啟動腳本
vi /etc/init.d/mailserver.mysql
------------------------------------------------------------------------------------------
basedir=/opt/mailserver/mysql
extra_args="-e $basedir/my.cnf" 改成 extra_args="-c $basedir/my.cnf"
$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
改成
$bindir/mysqld_safe --defaults-file=$basedir/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
----------------------------------------------------------------------------------------------
剩余的配置,就是修改$basedir/my.cnf文件內的內容,主要是mysql.sock的路徑,此處
我的配置是/opt/mailserver/mysql/data/mysql/mysql.sock
注意,data目錄最好是777權限,以免出錯。
安裝:cyrus-sasl
這個軟件是提供smtp的sasl驗證的,因為本次最終是采用dovecot進行smtp驗證,因此實際也沒有利用這個軟件的功能,考慮以后進行完善。
tar xzvf cyrus-sasl-2.1.22.tar.gz
cd cyrus-sasl-2.1.22
./configure --prefix=/opt/mailserver/cyrus-sasl --enable-login --enable-sql --disable-digest --with-openssl=/opt/mailserver/openssl --with-mysql=/opt/mailserver/mysql/
如何沒有采用--disable-digest,有可能會編譯不通過,在我的機器上是這樣,Google后才知道要禁用。
下面先備份老的sasl安裝包
mv /usr/lib/sasl /usr/lib/sasl.off
mv /usr/lib/sasl2 /usr/lib/sasl2.off
mv /usr/lib64/sasl2 /usr/lib64/sasl2.off //64位機器上需要運行
make
make install
下面的步驟,主要是對讓系統找到庫文件和頭文件,對于不同的系統,可能會有不同的操作。
ln -s / opt/mailserver/cyrus-sasl /usr/local/sasl2
ln -s /opt/mailserver/cyrus-sasl/lib/* /lib64
?
安裝:dovecot
tar xzvf dovecot-1.2.11.tar.gz
cd dovecot-1.2.11
./configure --prefix=/opt/mailserver/dovecot --with-ldap=yes --sysconfdir=/etc/dovecot --with-mysql --with-ssl=openssl --with-ssl --with-ssldir=/etc/ssl
make
make install
這個--with-ldap=yes參數我不記得是否加上了,而且即使不加上,默認應該是開啟的,具體的可參考./configure -help
安裝:Postfix
Postfix的安裝需要支持mysql,默認的包安裝方式是不支持的。
在這里我們讓它支持mysql,ssl,sasl
groupadd -g postfix
useradd -g postfix -c postfix -d /dev/null -s /bin/false postfix
groupadd postdrop
make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/opt/mailserver/mysql/include -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/opt/mailserver/cyrus-sasl/include -DUSE_TLS -I/opt/mailserver/openssl/include ' 'AUXLIBS=-L/opt/mailserver/mysql/lib -lmysqlclient -lz -lm -L/ opt/mailserver/cyrus-sasl/lib -lsasl2 -L/opt/mailserver/openssl/lib64 -lssl -lcrypto'
make
make install
make install時可以用來定義配置文件的存放位置,在這里,除了postfix.conf配置文件
全部放在了/opt/mailserver/postfix內部。
安裝完成后,
用postconf -a 來檢查是否安裝了sasl
用postconf -m 來檢查是否安裝了mysql
安裝:apache2
Apache編譯時加載全部模塊
tar xzvf cd httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure
--prefix=/opt/mailserver/apache2
-enable-so
--enable-modules=all
--enable-mods-shared=all
-enable-so表示支持動態模塊
--enable-modules=all表示編譯所有模塊
--enable-mods-shared=all 表示全部采用動態模塊
其他參數參照:
http://hi.baidu.com/sheshi37c/blog/item/0455247fc7c1450029388a1e.html
make
make install
實際不需要全部將這些模塊都編譯,我這里只是為了想用Apache的mod_status和mod_info模塊來查看所有服務器信息和模塊安裝情況,就和php安裝后的phpinfo()函數一樣,而又不想一個一個研究這些模塊,
安裝完成后,修改httpdconf,加入
Include conf/extra/httpd-info.conf
如果是完整安裝,./conf/extra/httpd-info.conf文件已經為你寫好了。
只要修改Allow from 部分,修改為 Allow from all,就可以在
http://servername/server-status 和
http://servername/server-info 中查看所有的apache2信息了。
conf/extra/httpd-info.conf中配置如下:
<Location /server-status>
SetHandler server-status
Order allow,deny
Deny from nothing
Allow from all
</Location>
<Location /server-info>
SetHandler server-info
Order allow,deny
Deny from nothing
Allow from all
</Location>
http://your.server.name/server-status?refresh=N訪問狀態頁面可以每N秒自動刷新一次。
http://your.server.name/server-status?auto獲得一個面向機器可讀的狀態文件
perl模塊安裝
參考
http://perl.apache.org/docs/2.0/user/install/install.html#Dynamic_mod_perl
tar xzvf mod_perl-2.0-current.tar.gz
cd mod_perl-2.0.4
perl Makefile.PL MP_AP_PREFIX=/opt/mailserver/apache2
make
make install
vi http.conf加入
LoadModule perl_module modules/mod_perl.so
?
fast-cgi模塊安裝
tar xzvf mod_fastcgi-2.4.6.tar.gz
cd mod_fastcgi-2.4.6
vi makefile
把/usr/local/httpd改成 /opt/mailserver/apache2
make
make intall
vi httpd.conf 加入
LoadModule fastcgi_module modules/mod_fastcgi.so
suexec模塊安裝
參考
http://bbs.linuxphp.org/thread-499-1-1.html
http://1kankan.com/ApacheManual/suexec.html
http://blog.5ilinux.com/archives/2006/07/
/opt/mailserver/apache2/bin/apxs -c mod_suexec.c
/opt/mailserver/apache2/bin/apxs -i -a -n suexec ./.libs/mod_suexec.so
cd ../../
./configure
--prefix=/opt/mailserver/apache2
-enable-so
--enable-suexec
--with-suexec-bin=/opt/mailserver/apache2/bin/suexec
--with-suexec-logfile=/var/log/suexec.log
--with-suexec-caller=daemon
--with-suexec-docroot=/srv/www/rcac
--enable-modules=all --enable-mods-shared=all
make suexec
make install-suexec
完成后用/opt/mailserver/apache2/bin/suexec -V 查看參數
?
安裝:php5
因為postfixadmin需要用到imap和mbstring以及mysql,需要php5安裝支持imap,mbstring,mysql
imap的安裝,費了很多的時間,可參照
http://www.phpbuilder.com/board/showthread.php?p=10944374
對于imap安裝另一種說法可能比較權威參照
http://squirrelmail.org/docs/admin/admin-3.html#ss3.2
根據文中所說SSLTYPE=unix表示用Openssl,SSLTYPE=unix表示用IMAP的ssl
make port-name PASSWDTYPE='' SSLTYPE=none
port-name 可從Makefile針對自己的系統查詢,對于SUSE是lsu
因為我裝了openssl, 所以我的參數是
make port-name PASSWDTYPE='' SSLTYPE=none
參考的安裝方法見下面
通過yast安裝pam-devel
wget ftp://ftp.cac.washington.edu/mail/imap.tar.Z
tar zxf imap.tar.Z
cd imap-2007a
vi Makefile
-----------------------------
Find EXTRACFLAGS=
and add change it to: //對于64位系統要增加額外的-fPIC選項
EXTRACFLAGS=-fPIC
-----------------------------
make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd IP6=4
echo "set disable-plaintext nil" > /etc/c-client.cf
mkdir /usr/local/imap-2007a
mkdir /usr/local/imap-2007a/include/
mkdir /usr/local/imap-2007a/lib/
chmod -R 077 /usr/local/imap-2007a
rm -rf /usr/local/imap-2007a/include/*
rm -rf /usr/local/imap-2007a/lib/*
rm -rf /usr/sbin/imapd
cp imapd/imapd /usr/sbin/
cp c-client/*.h /usr/local/imap-2007a/include/
cp c-client/*.c /usr/local/imap-2007a/lib/
cp c-client/c-client.a /usr/local/imap-2007a/lib/libc-client.a
此時,對于編譯php5有2種方法,一種采用所有參數放在php5 config命令
另一種,先按照默認的配置編譯,然后用模塊分別安裝的方法安裝
不知道為什么,我用第一種方法安裝后找不到模塊文件或者說無法啟用這些支持的模塊,所以最后采用的是第二種方法。
第一種方法的參數是
./configure
--prefix=/opt/mailserver/php5
--with-apxs2=/opt/mailserver/apache2/bin/apxs
--with-mysql=/opt/mailserver/mysql
--enable-mbstring
--with-imap=/opt/mailserver/imap
SSLTYPE=unix
--with-imap-ssl
--with-openssl
--with-config-file-path=/opt/mailserver/php5
cp php.ini-production /opt/mailserver/php5/php.ini
編譯時,如果不加SSLTYPE=unix會出現錯誤,提示庫不匹配,原因可能如下
this is because php won't use IMAP without SSL. for some people building IMAP with SSL doesn't work and the compile IMAP with this option SSLTYPE=none
in order to make IMAP compile u need to install openssl to this folder:
/usr/local/ssl
make shure u have the ssl libs accesible too in /usr/local/ssl/lib or /lib
after that IMAP should compile just fine with SSLTYPE=unix
?
參考:
http://www.phpbuilder.com/board/showthread.php?p=10944374
因為我的openssl是安裝在/opt/mailserver/openssl上的,默認的是要查找/usr/local/ssl
所以要做如下鏈接
ln -s /opt/mailserver/openssl /usr/local/ssl
第二種方法
----------------------------------------------------------------------------------------------------------------------
使用php的常見問題是:編譯php時忘記添加某擴展,后來想添加擴展,但是因為安裝php后又裝了一些東西如PEAR等,不想刪除目錄重裝,于是可以采用phpize。方法是:
要有與現有php完全相同的php壓縮包 。我用的是php-5.2.6.tar.gz。展開后進入里面的ext/mcrypt目錄 (里面是mcrypt的php擴展),然后執行/usr/local/php/bin/phpize。phpize是安裝php時安裝好的一個工具,如果你的機器沒有安裝phpize工具,那么可能還是要make,make install php,僅僅為了得到phpize.
執行完后,會發現當前目錄下多了一些configure文件,如果沒報錯,則根據提示運行
./configure --with-php-config=/usr/local/php/bin/php-config
注意要先確保/usr/local/php/bin/php-config存在。
make
make install
Php代碼
./configure --with-php-config=/usr/local/php/bin/php-config
make install 之后系統會提示你mcrypt.so文件所在的目錄。根據php.ini中指示的extension_dir指向的目錄中, 將其復制過去。修改php.ini,在最后添加一句extension=mcrypt.so
----------------------------------------------------------------------------------------------------------------------
具體方法參考
http://bbs2.chinaunix.net/viewthread.php?tid=1472578
我的步驟如下
先進入php目錄編譯默認的Php5主要命令是
./configure
--prefix=/opt/mailserver/php5
--with-apxs2=/opt/mailserver/apache2/bin/apxs
--with-mysql=/opt/mailserver/mysql
--with-config-file-path=/opt/mailserver/php5
cp php.ini-production /opt/mailserver/php5/php.ini
然后安裝imap模塊和mbstring模塊
cd ext
cd imap
/opt/mailserver/php5/bin/phpize //完成后,該目錄會生成configure文件
./configure
--with-imap=/opt/mailserver/imap
--with-openssl
--with-php-config=/opt/mailserver/php5/bin/php-config
make
make install
從屏幕提示中得到模塊文件的安裝位置,將它拷貝到自己定制的extensions目錄。
然后修改php.ini,在末尾加入extensions=/opt/mailserver/php5/extensions/imap.so
cd ext
cd mbstring
./configure
--enable-mbstring
--with-php-config=/opt/mailserver/php5/bin/php-config
make
make install
同上,拷貝模塊文件后在php.ini中加入
然后重新啟動apache2
安裝:Postfixadmin
網絡上橡皮老師有個postfixadmin安裝講座,采用的是2.1.1版本,該版本有個txt數據庫腳本用來導入數據庫,而2.2以上的版本不一樣,所以安裝步驟依據各個版本會有很大差別這里采用的版本是2.3版本,但是數據庫生成部分不是按照INSTALL文件里的說明操作的。因為按照說明文件操作后,總是提示連接不上數據庫,后來下載了2.1.1版本,從該版本中的txt腳本文件導入到數據庫中,再按照下面的步驟進行操作。
cd /opt/mailserver
tar -xvzf ~/Desktop/postfixadmin-2.3.tar.gz
mv postfixadmin-2.3.1 postfixadmin
vi postfixadmin/config.inc.php
$CONF['configured'] = true;
$CONF['postfix_admin_url'] = '/postfixadmin';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixadmin';
$CONF['database_password'] = 'postfixadmin';
$CONF['database_name'] = 'postfix';
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['encrypt'] = 'cleartext';
$CONF['emailcheck_resolve_domain] = 'NO';
打開/opt/mailserver/apache2/conf/httpd.conf文件,加入下面一行
Alias /postfixadmin /usr/share/postfixadmin
重啟appache2服務
/opt/mailserver/apache2/bin/apachctl restart
在瀏覽器中打開http://localhost/postfixadmin/setup.php
如果沒有錯誤,就直接生成數據庫,并輸入密碼
如果提示錯誤,則需要解決錯誤。
通常的錯誤有
1.Php沒有找到數據庫支持。
2.無法連接數據庫對應的sock
3.配置文件中的用戶被拒絕訪問數據庫
4.配置文件中的用戶沒有權限創建數據庫
第一個錯誤,通常是php編譯的時候沒有加入mysql支持
第二次錯誤,通常是sock文件目錄權限設置錯誤,或者是sock文件路徑定義的錯誤。
這個地方很復雜,php查找sock文件的配置可以再php.ini的文件中配置,而mysql啟動時建立的sock文件路徑可以再啟動腳本中進行配置。一般sock所在文件夾用戶和組都為
mysql,而且權限高于755或者直接設置成777,如果還是無法連接數據庫,則應該檢查
mysqld進程和mysqld_safe進程,保證這2個進程都被啟動,特別在多個版本的mysql數據庫被啟動的時候。
第三個錯誤,通常是數據庫的初始化錯誤。
這個地方也折騰了很長時間,對mysql刪除用戶和權限設置不熟悉,總是提示命令錯誤,無法創建用戶,最后不得不采用重新安裝數據庫,
其實最徹底的方法就是重新安裝mysql。
第四個錯誤,一般是因為配置文件的用戶沒有權限訪問Postfix數據庫,
手動進入mysqls數據庫,加入下面的2句命令就可以了。
grant all privileges on postfix.* to postfixadmin@localhost identified by 'postfixadmin';
flush privileges;
如果setup.php那里沒有錯誤,那么就可以設置系統密碼,然后直接創建管理員賬戶了。
創建的系統密碼,會自動生成hash值,并顯示出來,將它替換config.inc.php文件中的
setup passwd項。
創建完管理員賬號,打開http://localhost/postfixadmin/login
就可以開始管理賬戶了。
接下來開始進入配置文件
我基本上采用的是橡皮樹老師的配置。
下面貼上配置文件
/etc/postfix/main.cf
#-------------postfix install------------------------------------------------
queue_directory = /opt/mailserver/postfix/spool
command_directory = /opt/mailserver/postfix/sbin
daemon_directory = /opt/mailserver/postfix/daemon
data_directory = /opt/mailserver/postfix/caches
mail_owner = postfix
unknown_local_recipient_reject_code = 550
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
debug_peer_level = 2
debug_peer_list = 127.0.0.1
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = /opt/mailserver/postfix/html
manpage_directory = /opt/mailserver/postfix/man
sample_directory = /etc/postfix
readme_directory = /opt/mailserver/postfix/readme
#----------------------------------------------------------------------------
#-------------------------------------base-----------------------------------
myhostname = mail.rcac.xhu.edu.cn
mydomain = rcac.xhu.edu.cn
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
myorigin = $mydomain
mydestination = $myhostname localhost localhost.$mydomain
mynetworks = 127.0.0.0/8
inet_interfaces = all
#----------------------------------------------------------------------------
#-------------vritual mailbox settings----------------------------------------
#virtual_minimum_uid = static:50
virtual_uid_maps = static:2001
virtual_gid_maps = static:2001
virtual_transport = virtual
virtual_mailbox_base = /opt/mailserver/postfix/spool/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_alias_domains =
maildrop_destination_recipient_limit=1
maildrop_destination_concurrency_limit=1
#----------------------------------------------------------------------------
#-----------------------------------quota------------------------------------
message_size_limit = 52428800
mailbox_size_limit = 209715200
virtual_mailbox_limit = 209715200
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his disk space quota,please try again later.
virtual_overquota_bounce = yes
#----------------------------------------------------------------------------
#-------------------------------------SASL-----------------------------------
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = $myhostname ESMTP "Version not Available"
#----------------------------------------------------------------------------
/etc/postfix/mysql_virtual_alias_maps.cf
#----------------------------------------------------------------------------
user = postfix
password = postfix
hosts = unix:/opt/mailserver/mysql/data/mysql/mysql.sock
dbname = postfix
table = alias
select_field = goto
where_field = address
#----------------------------------------------------------------------------
mysql_virtual_domains_maps.cf
#----------------------------------------------------------------------------
user = postfix
password = postfix
hosts = unix:/opt/mailserver/mysql/data/mysql/mysql.sock
dbname = postfix
table = domain
select_field = description
where_field = domain
#----------------------------------------------------------------------------
?
mysql_virtual_mailbox_limit_maps.cf
#----------------------------------------------------------------------------
user = postfix
password = postfix
#hosts = localhost
hosts = unix:/opt/mailserver/mysql/data/mysql/mysql.sock
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#----------------------------------------------------------------------------
mysql_virtual_mailbox_maps.cf
#----------------------------------------------------------------------------
user = postfix
password = postfix
#hosts = localhost
hosts = unix:/opt/mailserver/mysql/data/mysql/mysql.sock
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
#----------------------------------------------------------------------------
/etc/dovecot/dovecot.conf
#----------------------------------------------------------------------------
base_dir = /var/run/dovecot/
protocols = imap pop3
listen = *
auth_verbose=yes
auth_debug=yes
auth_debug_passwords=yes
mail_debug=yes
verbose_ssl=yes
disable_plaintext_auth = no
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot-info.log
ssl = no
#ssl_disable = yes
mail_location = maildir:/opt/mailserver/postfix/spool/mailbox/%d/%n
auth default {
mechanisms = PLAIN LOGIN CRAM-MD5 DIGEST-MD5
passdb sql {
args=/etc/dovecot/dovecot-mysql.conf
}
userdb sql {
args=/etc/dovecot/dovecot-mysql.conf
}
user = root
socket listen {
client {
path = /var/run/dovecot/auth-client
mode = 0660
user=postfix
group=postfix
}
}
}
#----------------------------------------------------------------------------
/etc/dovecot/dovecot-mysql.conf
#----------------------------------------------------------------------------
driver = mysql
connect=host=/opt/mailserver/mysql/data/mysql/mysql.sock dbname=postfix user=postfix password=postfix
default_pass_scheme=plain
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir,2001 AS uid,2001 AS gid FROM mailbox WHERE username='%u'
#----------------------------------------------------------------------------
對于數據庫的配置
直接下載postfixadmin 2.1.1版本,解壓縮后有一個用戶mysql的數據庫生成語句寫的txt文件直接導入到mysql即可,然后再根據上面所說的方法配置postfixadmin。
對于SquirrelMail 的配置比較簡單
解壓縮后,運行目錄下的./configure就會進入配置文件
具體步驟如下
root@node8:/opt/mailserver/squirrelmail # ./configure
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 >>
選擇1
Command >> 1
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Organization Preferences
1. Organization Name : rcac
2. Organization Logo : ../images/sm_logo.png
3. Org. Logo Width/Height : (308/111)
4. Organization Title : rcac
5. Signout Page :
6. Top Frame : _top
7. Provider link : http://rcac.xhu.edu.cn/postfixadmin/users
8. Provider name : change password
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
修改Organization Name Organization Title 返回
選擇2
Command >> 2
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain : rcac.xhu.edu.cn
2. Invert Time : false
3. Sendmail or SMTP : SMTP
A. Update IMAP Settings : localhost:143 (dovecot)
B. Update SMTP Settings : localhost:25
R Return to Main Menu
C Turn color on
S Save data
Q Quit
修改域名,和服務器類型,此處是smtp,修改A對應的imap軟件名以及端口等,返回
選擇4修改全局設置
Command >> 4
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
General Options
1. Data Directory : /srv/www/rcac/webmail/attachments/
2. Attachment Directory : /srv/www/rcac/webmail/data/
3. Directory Hash Level : 0
4. Default Left Size : 150
5. Usernames in Lowercase : false
6. Allow use of priority : true
7. Hide SM attributions : false
8. Allow use of receipts : true
9. Allow editing of identity : true
Allow editing of name : true
Remove username from header : false
10. Allow server thread sort : false
11. Allow server-side sorting : false
12. Allow server charset search : true
13. Enable UID support : true
14. PHP session name : SQMSESSID
15. Location base :
16. Only secure cookies if poss. : true
17. Disable secure forms : false
18. Page referal requirement :
R Return to Main Menu
C Turn color on
S Save data
Q Quit
Command >>
修改Data Directory,Attachment Directory,這個目錄的權限需要設置成777
最后選擇S保存推出。
此時所有參數都是寫在config.php文件中,為了郵件用戶能夠通過webmail改密碼,需要修改config.php文件中的下面2個參數
$provider_uri = 'http://rcac.xhu.edu.cn/postfixadmin/users'; //到postfixadmin的接口。
$provider_name = 'change password';
接下來
在目錄/srv/www/rcac/處新建2個連接
ln -s /opt/mailserver/SquirrelMail /srv/www/rcac/webmail
ln -s /opt/mailserver/postfixadmin /srv/www/rcac/postfixadmin
然后再httpd.conf中將/srv/www/rcac/加到根目錄
訪問主頁下的weimail即進入登陸界面,填寫在postfixadmin中已經定義的帳戶和密碼即可登陸web郵箱了。
總結:
此次配置主要有如下難點
1. Mysql數據庫的導入,雖然原理很簡單,但是總是提示用戶已經存在,原因是采用2.2.3的方法加入建立的數據庫,后來又想通過2.1.1的方法來導入,最后想刪除用戶卻總是刪除不了用戶信息,不得不重新安裝mysql
2. Php5總是連接不上mysql,提示無法連接到sock文件,或者是用戶沒有權限,最終查到原因是mysql的啟動不完整,以及my.cnf配置文件中的sock文件小錯誤。
3. Php5的imap模塊的安裝,這個地方總是會出現編譯錯誤,找不到庫文件。
4. Postfix中關于mysql的sock路徑指定參數,Google了很長時間,才找到這個配置參數。
否則總是在取數據庫那里出錯,因為它默認利用的是/tmp/mysql.sock
5. postfix uid和gid最好要大于100或更高,否則雖然安裝橡皮樹老師設置的方法,最后還是不能成功,我最后采用了2001這個很高的uid和gid.
?
參考:
postfix系統用戶smtp認證超簡單配置
http://www.redlinux.org/read.php?tid-481.html
openssl+cyrus-sasl2+Berkeley DB+postfix
特點:
1) 本地系統用戶
2) 不使用數據庫
3) 使用dovecot做smtp認證,簡單實用
4) 安裝配置過程簡單
linux下編譯postfix時,使其支持mysql,ldap,sasl,ssl的腳本
http://lovesea.blog.51cto.com/382446/102732
?
redhat4.0up2+postfix+dovecot (源碼安裝) 實現虛擬用戶,SMTP認證,POP3
http://hi.baidu.com/suping/blog/item/a03b793e5664ee3170cf6cc1.html
?
postfix+sasl+mysql+dovecot+apache+php 郵件服務器成功配置筆記
http://oldhand.3ren.com/profiles/blog/show?id=2795388334018897%3ABlogPost%3A2888407217226852
?
Exmail論壇
http://www.extmail.org/forum/
?
linux 用icc編譯mysql
http://www.boobooke.com/bbs/thread-2999-1-1.html
?
linux下編譯安裝postfix+mysql+dovecot+postfixadmin
http://www.nginxs.com/linux/69.html
?
OpenLdap 與 BerkeleyDB 安裝過程
http://blog.chinaunix.net/u1/56685/showart_1830385.html
?
Linux Apache2 + mysql5 + php5安裝詳解
http://linux.chinaunix.net/techdoc/database/2008/03/04/981250.shtml
?
郵件系統的安裝
http://bbs.chinaunix.net/viewthread.php?tid=987344
Php imap的安裝
http://hi.baidu.com/chenshake/blog/item/8266d4eae70d4cd6d439c9f9.html
http://www.phpbuilder.com/board/showthread.php?p=10944374
postfixadmin
http://www.linuxmail.info/postfix-admin-howto-centos-5/
php擴展的安裝
http://bbs2.chinaunix.net/viewthread.php?tid=1485530
實用命令:利用openssl進行BASE64編碼解碼、md5/sha1摘要、AES/DES3加密解密
http://www.cppblog.com/sleepwom/archive/2010/01/05/104818.html
Trouble with virtual delivery
http://archives.neohapsis.com/archives/postfix/2005-04/0147.html
用SMTP/POP3訪問郵箱暨SMTP/POP3原理
http://blog.163.com/sq-shi/blog/static/9310552120094173533027/
postfix virtual MySQL
hosts = unix:/var/run/mysqld/mysqld.sock
http://www.postfixvirtual.net/postfixconf.html
Trouble with virtual delivery
http://archives.neohapsis.com/archives/postfix/2005-04/0147.html
postfix+dovecot+postfixadmin+mysql認證
http://bbs.chinaunix.net/viewthread.php?tid=1638787
RHEL4上安裝基于postfix的全功能郵件服務器(全部使用目前最新源碼包構建)
http://www.chinaunix.net/jh/14/987344.html
apache 動態編譯 靜態編譯
http://hi.baidu.com/sheshi37c/blog/item/0455247fc7c1450029388a1e.html
Postfix電子郵件系統完整安裝教程
http://www.info110.com/map.asp?pid=14824
ExtMail Solution HOWTO for Linux
http://www.extmail.org/docs/extmail_solution_linux/#extmail
How to set up a mail server on a GNU / Linux system
Ubuntu + Postfix + Courier IMAP + MySQL + Amavisd-new +
SpamAssassin + ClamAV + SASL + TLS + SquirrelMail/Roundcube + Postgrey
http://flurdy.com/docs/postfix/
Mail server HOWTO
Postfix + Dovecot +Mysql+TLS/SSL+postgrey+DSPAM
http://johnny.chadda.se/article/mail-server-howto-postfix-and-dovecot-with-mysql-and-tlsssl-postgrey-and-dspam/
Creating a Linux Mail Server
(Postfix, Procmail, Fetchmail, SpamBayes, Courier-imap, Mutt, SquirrelMail)
http://www.hypexr.org/linux_mail_server.php
Secure Virtual Mailserver HOWTO
Postfix + OpenLDAP + Dovecot + Jamm + SASL + SquirrelMail
http://wanderingbarque.com/howtos/mailserver/mailserver.html
?
Debian Mail Server Setup with Postfix + Dovecot + SASL + Squirrel Mail
http://www.debianadmin.com/debian-mail-server-setup-with-postfix-dovecot-sasl-squirrel-mail.html
How to setup Relay host in mail server
http://webmail.tm.net.my/info/smtp-proxy.html
?
總結
以上是生活随笔為你收集整理的配置postfix+dovecot+mysql+postfixadmin+squirrelmail 邮件系统笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一款因为高颜值而被人挂念的微单
- 下一篇: 官网源代码显示微软 Build 2023