歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> Unix教程

在FreeBSD上建立一個功能完整的郵件服務器

FreeBSD郵件服務器


  第一部分:安裝郵件服務器:postfix+vm-pop3d+openwebmail
  以下的安裝在FreeBSD 5.2.1系統上完成
  
  1.更新 ports
  
  # cvsup -gL 2 -h cvsup.freebsdchina.org /usr/share/examples/cvsup/ports-supfile
  
  2. 安裝 openssl+apache 服務器
  
  # cd /usr/ports/security/openssl
  # make install
  # make clean
  # cd /usr/ports/www/apache2
  # make install
  # make clean
  # vi /etc/rc.conf
  
  apache2_enable="YES"
  
  3. 安裝 openwebmail
  
  # cd /usr/ports/mail/openwebmail/
  # make WITH_QUOTA=yes install
  # make clean
  
  4. 安裝 postfix ,在安裝過程中用yes回答提出的問題
  
  # cd /usr/ports/mail/postfix/
  # make install
  # make clean
  
  # vi /etc/rc.conf
  
  為了能啟動postfix加入:
  
  sendmail_enable="YES"
  sendmail_flags="-bd"
  sendmail_pidfile="/var/spool/postfix/pid/master.pid"
  sendmail_outbound_enable="NO"
  sendmail_submit_enable="NO"
  
  5. 安裝 vm-pop3d
  
  # cd /usr/ports/mail/vm-pop3d
  # make install
  # make clean
  
  6. 配置 postfix
  
  # vi /usr/local/etc/postfix/main.cf
  
  添加:
  
  virtual_alias_maps=hash:/usr/local/etc/postfix/virtual
  alias_maps=hash:/usr/local/etc/postfix/aliases
  default_privs=nobody
  allow_mail_to_commands = alias,forward,include
  allow_mail_to_files = alias,forward,include
  
  下面我加入一個 nero.3322.org 的虛擬域,並添加一個用戶llzqq
  # vi /usr/local/etc/postfix/virtual
  
  添加:
  
  nero.3322.org anything //之間用[tab]
  [email protected] llzqq.nero.3322.org //之間用[tab]
  
  執行下面的命令,生成 virtual.db:
  
  # cd /usr/local/etc/postfix/
  # postmap virtual
  
  # vi /usr/local/etc/postfix/aliases
  
  添加:
  
  llzqq.nero.3322.org:/var/spool/virtual/nero.3322.org/llzqq
  
  執行下面的命令,生成 aliases.db:
  
  # cd /usr/local/etc/postfix
  # postalias aliases
  
  
  7. 配置 vm-pop3d 使其開機自動執行
  
  # cd /usr/local/etc/rc.d
  # mv vm-pop3d.sh.sample vm-pop3d.sh
  
  配置 openwebmail 支持 nero.3322.org 域,創建下面的文件:
  
  # vi /usr/local/www/cgi-bin/openwebmail/etc/sites.conf/nero.3322.org
  
  =========================== nero.3322.org =======================
  auth_module auth_vdomain.pl
  auth_withdomain yes
  mailspooldir /var/spool/virtual/nero.3322.org
  use_syshomedir no
  use_homedirspools no
  enable_autoreply no
  enable_setforward no
  enable_vdomain yes
  vdomain_admlist llzqq //這裡設置了這個域的管理員
  vdomain_maxuser 500
  vdomain_vmpop3_pwdpath /usr/local/etc/virtual
  vdomain_vmpop3_pwdname passwd
  vdomain_vmpop3_mailpath /var/spool/virtual
  vdomain_postfix_aliases /usr/local/etc/postfix/aliases
  vdomain_postfix_virtual /usr/local/etc/postfix/virtual
  vdomain_postfix_postalias /usr/local/sbin/postalias
  vdomain_postfix_postmap /usr/local/sbin/postmap
  # quota設置部分
  quota_module quota_du.pl
  quota_limit 52400 //定義了郵箱大小
  quota_threshold 85
  delmail_ifquotahit no
  delfile_ifquotahit no
  =========================== nero.3322.org =======================
  
  # mkdir -p /var/spool/virtual/nero.3322.org
  # chown nobody /var/spool/virtual/nero.3322.org
  # chgrp mail /var/spool/virtual/nero.3322.org
  
  # mkdir -p /usr/local/etc/virtual/nero.3322.org
  # touch /usr/local/etc/virtual/nero.3322.org/passwd
  # chmod 644 /usr/local/etc/virtual/nero.3322.org/passwd
  
  # htpasswd /usr/local/etc/virtual/nero.3322.org/passwd llzqq
  # chmod 755 /usr/local/www/cgi-bin/openwebmail/etc/users
  
  # sync
  # reboot
  
  8. 最後通過浏覽器登陸到OPENWEBMAIL
  
  http://nero.3322.org/cgi-bin/openwebmail/openwebmail.pl
  
  第二部分:防病毒、垃圾郵件:clamav+amavisd-new+spam
  1.0 安裝clamav:
  
  # cd /usr/ports/security/clamav
  # make install
  # make clean
  
  # vi /usr/local/etc/clamav.conf
  ===============================clamav.conf============================
  # Comment or remove the line below.
  # Example
  LogFile /var/log/clamav/clamd.log
  LogFileMaxSize 1M
  LogTime
  LogVerbose
  PidFile /var/run/clamav/clamd.pid
  DataDirectory /usr/local/share/clamav
  LocalSocket /tmp/clamd
  StreamMaxLength 10M
  MaxThreads 10
  MaxDirectoryRecursion 15
  User clamav
  ScanMail
  ScanArchive
  ScanRAR
  ArchiveMaxFileSize 10M
  ArchiveMaxRecursion 5
  ArchiveMaxFiles 1000
  ClamukoScanOnOpen
  ClamukoScanOnClose
  ClamukoScanOnExec
  ClamukoIncludePath /var/spool/virtual
  ClamukoMaxFileSize 6M
  ClamukoScanArchive
  ===============================clamav.conf============================
  
  1.1 更新病毒庫
  
  # /usr/local/etc/rc.d/clamav-freshclam.sh start
  
  2.0 安裝amavisd-new
  
  # cd /usr/ports/security/amavisd-new
  # make install
  # make clean
  
  # cd /usr/local/etc
  # mv amavisd.conf-dist amavisd.conf
  # vi amavisd.conf
  ============================== amavisd.conf ===============================
  $MYHOME = '/var/amavis'; # (default is '/var/amavis')
  $mydomain = 'nero.3322.org'; # (no useful default)
  $daemon_user = 'vscan'; # (no default; customary: vscan or amavis)
  $daemon_group = 'vscan'; # (no default; customary: vscan or amavis)
  
  $log_level = 0;
  
  $sa_spam_subject_tag = '***SPAM***'
  
  $virus_admin = "root\@$mydomain";
  $spam_admin = "llzqq\@$mydomain";
  $mailfrom_notify_admin = "llzqq\@$mydomain";
  $mailfrom_notify_recip = "llzqq\@$mydomain";
  $mailfrom_notify_spamadmin = "llzqq\@$mydomain";
  
  $inet_socket_bind = '127.0.0.1';
  $forward_method = 'smtp:127.0.0.1:10025';
  $notify_method = $forward_method;
  $inet_socket_port = 10024;
  $max_servers = 2;
  
  ['Clam Antivirus-clamd',
  \&ask_daemon, ["CONTSCAN {}\n", '/tmp/clamd'],
  qr/\bOK$/, qr/\bFOUND$/,
  qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
  ============================== amavisd.conf ===============================
  
  2.1 要啟動clamav和amavisd-new需要配置一下/etc/rc.conf
  
  # vi /etc/rc.conf
  
  spamd_enable="YES"
  amavisd_enable="YES
  clamav_clamd_enable="YES"
  
  
  3.0 由於在安裝amavisd-new時spamassassin被一起安裝了下面對其進行配置
  
  3.1 建立過濾規則:
  
  # cd /usr/local/etc/mail/spamassassin
  # env LANG=C vi local.cf
  =============================== local.cf ===============================
  # SpamAssassin config file for version x.xx
  # generated by http://www.yrex.com/spam/spamconfig.php (version 1.01)
  
  # How many hits before a message is considered spam.
  required_hits 4.0
  
  # Whether to change the subject of suspected spam
  rewrite_subject 1
  
  # Text to prepend to subject if rewrite_subject is used
  subject_tag *****SPAM*****
  
  # Encapsulate spam in an attachment
  report_safe 1
  
  # Use terse version of the spam report
  use_terse_report 0
  
  # Enable the Bayes system

Copyright © Linux教程網 All Rights Reserved