Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux系统 > » 正文

Linux+Postfix+Extmail+Dovecot打造基于WEB页面的邮件系统(2)

来源: 未知 分享至:

二、安装配置postfix

#创建postfix用户

 groupadd -g2525 postfix   #大于一千最好 -g

 useradd -gpostfix -u 2525 -s /sbin/nologin -M postfix

groupadd -g 2526 postdrop

 useradd -gpostdrop -u 2526 -s /bin/false -M postdrop

假设准备阶段的软件包都存放在/mnt/postfix里

 tar zxvfpostfix-2.6.5.tar.gz

 cdpostfix-2.6.5

 make makefiles'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL-I/usr/include/sasl  -DUSE_TLS ''AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2   -lssl -lcrypto'

#gcc的编译选项;mysql头文件;支持sasl认证;cyrus_sasl的头文件;mysql的客户端;指明auxlibs的位置

make

make install

 

安装过程中会出现一些提示除了tempdir:改为/tmp,其他使用默认项,直接直接回车        

  install_root: [/] /

  tempdir:[/usr/local/src/ postfix-2.6.5] /tmp

  config_directory:[/etc/postfix] /etc/postfix

  daemon_directory:[/usr/libexec/postfix]

  command_directory:[/usr/sbin]

  queue_directory:[/var/spool/postfix]

  sendmail_path:[/usr/sbin/sendmail]

  aliases.html' target='_blank'>newaliases_path:[/usr/bin/newaliases]

  mailq_path:[/usr/bin/mailq]

  mail_owner: [postfix]

  setgid_group:[postdrop]  

   html_directory: [no] /var/www/postfix_html

    manpages:[/usr/local/man]

   readme_directory: [no]

安装后会由警告,不用理会

newaliases                                       # 生成别名二进制文件,可有可无,反正以后也要打

2.进行一些基本配置,测试启动postfix并进行发信

vi /etc/postfix/main.cf

修改以下几项为您需要的配置

myhostname = mail.dean.com

myorigin = dean.com

mydomain = dean.com

mydestination = $myhostname, localhost.$mydomain,localhost, $mydomain

mynetworks = 192.1680.0/24, 127.0.0.1/8

 

说明:

myorigin参数用来指明发件人所在的域名;

mydestination参数指定postfix接收邮件时收件人的域名,即您的postfix系统要接收到哪个域名的邮件;

myhostname 参数指定运行postfix邮件系统的主机的主机名,默认情况下,其值被设定为本地机器名;

mydomain参数指定您的域名,默认情况下,postfix将myhostname的第一部分删除而作为mydomain的值;

mynetworks 参数指定你所在的网络的网络地址,postfix系统根据其值来区别用户是远程的还是本地的,如果是本地网络用户则允许其访问;

inet_interfaces 参数指定postfix系统监听的网络接口;

注意:

1、在postfix的配置文件中,参数行和注释行是不能处在同一行中的;

2、任何一个参数的值都不需要加引号,否则,引号将会被当作参数值的一部分来使用;

3、每修改参数及其值后执行 postfix reload 即可令其生效;但若修改了inet_interfaces,则需重新启动postfix;

4、如果一个参数的值有多个,可以将它们放在不同的行中,只需要在其后的每个行前多置一个空格即可;postfix会把第一个字符为空格或tab的文本行视为上一行的延续;

启动postfix

/usr/sbin/postfix start

#手动创建启动脚本

vim /etc/init.d/postfix

  1. #!/bin/bash   
  2. . /etc/rc.d/init.d/functions  
  3. . /etc/sysconfig/network  
  4. [ ${NETWORKING} = "no" ] && exit 0  
  5.    
  6. [ -x /usr/sbin/postfix ] || exit 0  
  7. [ -d /etc/postfix ] || exit 0  
  8. [ -d /var/spool/postfix ] || exit 0  
  9.    
  10. RETVAL=0  
  11. prog="postfix"  
  12.    
  13. start() {  
  14.        # Startdaemons.   
  15.        echo -n{1}quot;Starting postfix: "  
  16.        /usr/bin/newaliases >/dev/null 2>&1  
  17.        /usr/sbin/postfixstart 2>/dev/null 1>&2 && success || failure {1}quot;$progstart"  
  18.        RETVAL=$?  
  19.        [ $RETVAL-eq 0 ] && touch /var/lock/subsys/postfix  
  20.         echo  
  21.        return$RETVAL  
  22. }  
  23.    
  24. stop() {  
  25.         # Stopdaemons.   
  26.        echo -n{1}quot;Shutting down postfix: "  
  27.        /usr/sbin/postfixstop 2>/dev/null 1>&2 && success || failure {1}quot;$progstop"  
  28.        RETVAL=$?  
  29.        [ $RETVAL-eq 0 ] && rm -f /var/lock/subsys/postfix  
  30.        echo  
  31.        return$RETVAL  
  32. }  
  33.    
  34. reload() {  
  35.        echo -n{1}quot;Reloading postfix: "  
  36.        /usr/sbin/postfixreload 2>/dev/null 1>&2 && success || failure {1}quot;$progreload"  
  37.        RETVAL=$?  
  38.        echo  
  39.        return$RETVAL  
  40. }  
  41. abort() {  
  42.        /usr/sbin/postfixabort 2>/dev/null 1>&2 && success || failure {1}quot;$progabort"  
  43.        return $?  
  44. }  
  45. flush() {  
  46.        /usr/sbin/postfixflush 2>/dev/null 1>&2 && success || failure {1}quot;$progflush"  
  47.        return $?  
  48. }  
  49. check() {  
  50.        /usr/sbin/postfixcheck 2>/dev/null 1>&2 && success || failure {1}quot;$progcheck"  
  51.        return $?  
  52. }  
  53. restart() {  
  54.        stop  
  55.        start  
  56. }  
  57. # See how we were called.   
  58. case "$1" in  
  59.   start)  
  60.        start  
  61.        ;;  
  62.   stop)  
  63.        stop  
  64.        ;;  
  65.   restart)  
  66.        stop  
  67.        start  
  68.        ;;  
  69.   reload)  
  70.        reload  
  71.        ;;  
  72.   abort)  
  73.        abort  
  74.        ;;  
  75.   flush)  
  76.        flush  
  77.        ;;  
  78.   check)  
  79.        check  
  80.        ;;  
  81.   status)  
  82.       status master  
  83.        ;;  
  84.   condrestart)  
  85.        [ -f/var/lock/subsys/postfix ] && restart || :  
  86.        ;;  
  87.   *)  
  88.        echo{1}quot;Usage: $0{start|stop|restart|reload|abort|flush|check|status|condrestart}"  
  89.        exit 1  
  90. esac  
  91. exit $?  

-------------------------------------------------------------------------------------------

# 别忘了给执行权限

chmod +x /etc/init.d/postfix

chkconfig --add postfix                 # 这步可能加不,不用管它

 

连接postfix,验正服务启动状况:

[root@station71 postfix]# lnet.html' target='_blank'>telnet 192.168.0.71 25

Trying 192.168.0.71...

Connected to station71.RedHat_hu.com (192.168.0.71).

Escape character is '^]'.

220 mail.evo.com ESMTP Postfix

ehlo mail.evo.com

250-mail.evo.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:root@evo.com

250 2.1.0 Ok

rcpt to:root@evo.com

250 2.1.5 Ok

data

354 End data with<CR><LF>.<CR><LF>

subject:test

test 123...

.

250 2.0.0 Ok: queued as 7AAD51B803D

quit

221 2.0.0 Bye

Connection closed by foreign host.

You have mail in /var/spool/mail/root

[root@station71 postfix]# mail

Mail version 8.1 6/6/93.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1root@evo.com          Sun Aug 1420:03  15/481   "test"

#测试成功 

三、为postfix开启基于cyrus-sasl的认证功能

使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的:

/usr/sbin/postconf -a

cyrus

dovecot 

vi /etc/postfix/main.cf

添加以下内容:

  1. ############################CYRUS-SASL############################   
  2.   
  3. broken_sasl_auth_clients = yes  
  4.   
  5. #定义是否允许突破sasl认证   
  6.   
  7. 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  
  8.   
  9. #拒绝xxxxxxxxx   
  10.   
  11. smtpd_sasl_auth_enable = yes  
  12.   
  13. smtpd_sasl_local_domain = $myhostname  
  14.   
  15. smtpd_sasl_security_options = noanonymous  
  16.   
  17. smtpd_sasl_application_name = smtpd  
  18.   
  19. smtpd_banner = Welcome to our $myhostnameESMTP,Warning: Version has been hidden!  
  20.   
  21. #欢迎信息且隐藏版本号  

 

vi /usr/lib/sasl2/smtpd.conf

添加如下内容:

pwcheck_method: saslauthd

mech_list: PLAIN LOGIN

 

让postfix重新加载配置文件

/usr/sbin/postfix reload

service postfix restart

 

[root@station71 postfix]# telnet 192.168.0.32

Trying 192.168.0.32.

Connected to station71.RedHat_hu.com (192.168.0.32

Escape character is '^]'.

220 Welcome to our mail.evo.com ESMTP,Warning: Versionhas been hidden.

ehlo mail.evo.com

250-mail.evo.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN #有以上两行说明CYRUS-SASL认证添加成功

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

quit

221 2.0.0 Bye

Connection closed by foreign host.

#测试


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
相关文章列表:
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史