作者 主題: Exim with virtual domains  (閱讀 7079 次)

0 會員 與 1 訪客 正在閱讀本文。

usnei

  • 憂鬱的高中生
  • ***
  • 文章數: 128
    • 檢視個人資料
    • http://www.usnei.net
Exim with virtual domains
« 於: 2007-08-08 10:57 »
域名 usnei.net
funnyd.idv.tw
download exim4.67
tar -zxvf exim-4.6x
cp eximpath/src/EDITME eximpath/Local/Makefile
vi Makefile
unmark LOOKUP_LSEARCH=yes
unmark LOOKUP_DSEARCH=yes

EXIM_USER=exim
------------------------這邊是為了日後方便加入寄信驗證
AUTH_CRAM_MD5=yes
AUTH_CYRUS_SASL=yse
AUTH_LIBS=-lsasl2
SUPPORT_TLS=yes
TLS_LIBS=-lssl -lcrypto
TLS_INCLUDE=-I /usr/local/openssl/include/

mark EXIM_MONITOR=eximon.bin ---我覺得這個不好用
CYRUS_PWCHECK_SOCKET=/var/pwcheck/pwcheck
CYRUS_SASLAUTHD_SOCKET=/var/run/saslauthd/mux

wq
make
make install
vi /usr/exim/configure
begin router 區段加入
virtual_domains:
driver = accept
domains = dsearch;/etc/mail/Vdomains
local_parts = lsearch;/etc/mail/Vdomains/$domain
transport = my_virtual_mailboxes

注意 路徑與transport的名稱需自己先定義好
/etc/mail/Vdomains與 my_virtual_mailboxes

begin transports 區段加入
my_virtual_mailboxes:
driver=appendfile
file=/var/mail/Vdomains/$domain/$local_part
user=mail

注意local_delivery
group 與mode

以exim-4.67 為例
local_delivery:
driver = appendfile
file = /var/mail/$local_part
delivery_date_add
envelope_to_add
return_path_add
group = mail
mode = 0660

begin authenticators
unmark 以下

LOGIN:
driver = plaintext
server_set_id = LOGIN
server_prompts = Username: | Password:
server_condition = ${if crypteq {$2}{${lookup{$extract{1}{@}{1}}} lsearch{/etc/mail/VMPOP3D/${extract{2}{@}{$1}}/passwd}}} {yes} {no}}
server_advertise_condition = ${if def:tls_cipher }

以我configure 為例 建立以下目錄
mkdir -p /etc/mail/Vdomains
touch /etc/mail/Vdomains/usnei.net
touch /etc/mail/Vdomains/funnyd.idv.tw
mkdir -p /var/mail/Vdomains/usnei.net
mkdir -p /var/mail/Vdoamins/funnyd.idv.tw
新增usnei.net 的帳號
echo "admin" >> /etc/mail/Vdomains/usnei.net
新增funnyd.idv.tw 的帳號
echo "andrew" >> /etc/mail/Vdomains/funnyd.idv.tw
收信
使用Vm-pop3d
download
vi vmpop3dpath/vm-pop3d.h
define VIRTUAL_MAILPATH "/var/mail/Vdomains"
define VIRTUAL_PASSWORDS_PATH "/etc/mail/VMPOP3D"
./configure
make
make install
使用xinetd 管理vm-pop3d
vi /etc/xinetd.d/vm-pop3d
service pop-3
{
Disable = no
socket_type = stream
protocl = tcp
wait = no
user = mail
instances = 25
server = /usr/local/sbin/vm-pop3d
server_args = -i
log_type = SYSLOG local4 info
log_on_success = PID HOST EXIT DURATION
log_on_failure = HOST ATTEMPT
}
/etc/init.d/xinted restart
/sbin/chkconfig xinetd on
telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK POP3 Welcome to vm-pop3d 1.1.6 <30364.1186537646@usnei.net>

簡單新增密碼的小perl
vi /usr/sbin/vmakepasswd

#/usr/bin/perl
$name = $ARGV[0];
@salt_chars = ('a'..'z','A'..'Z','0'..'9');
$salt = $salt_chars[rand(62)].$salt_chars[rand(62)];
@passwd = crypt($ARGV[1],$salt);
print "$name:$passwd\n";
wq
chmod 755 /usr/sbin/vmakepasswd

mkdir -p /etc/mail/VMPOP3D/usnei.net
usnei.net 新增admin 密碼為passwd
vmakepasswd admin passwd >> /etc/mail/VMPOP3D/usnei.net/passwd

cat /etc/mail/VMPOP3D/usnei.net/passwd 驗證一下密碼

admin:1my3u0QwSZHEc

重新啟動exim services

Notes : email 帳號需使用完整mail address
EX:admin@usnei.net