本章测试

测试步骤

  1. check

    debian:~# postfix check
    			
  2. postconf

    debian:/etc/postfix# postconf -n 
    			
  3. smtp

    # mail [email protected] < /etc/hostname

    debian:~# ls /var/mail/example.net/
    chen
    debian:~# find /var/mail/example.net/
    /var/mail/example.net/
    /var/mail/example.net/chen
    /var/mail/example.net/chen/maildir
    /var/mail/example.net/chen/maildir/tmp
    /var/mail/example.net/chen/maildir/cur
    /var/mail/example.net/chen/maildir/new
    /var/mail/example.net/chen/maildir/new/1095370461.V306Ia262b8.localhost.localdomain
    debian:~#
    			

    example.net域下有文件夹说明邮件投递成功,恭喜你了!

    如果没成功请查看/var/log/mail.log

    一封被正确投递的邮件日志应该是:

    Sep 17 13:39:35 localhost postfix/smtpd[8699]: connect from unknown[192.168.0.254]
    Sep 17 13:39:35 localhost postfix/smtpd[8699]: 487EE49BA3F: client=unknown[192.168.0.254]
    Sep 17 13:39:35 localhost postfix/cleanup[8701]: 487EE49BA3F: message-id=<[email protected]>
    Sep 17 13:39:35 localhost postfix/qmgr[8682]: 487EE49BA3F: from=<[email protected]>, size=584, nrcpt=1 (queue active)
    Sep 17 13:39:35 localhost postfix/virtual[8686]: 487EE49BA3F: to=<[email protected]>, relay=virtual, delay=0, status=sent (delivered to maildir)
    Sep 17 13:39:35 localhost postfix/qmgr[8682]: 487EE49BA3F: removed
    Sep 17 13:39:35 localhost postfix/smtpd[8699]: disconnect from unknown[192.168.0.254]
    			
  4. sasl

    AUTH PLAIN

    debian:~# perl -MMIME::Base64 -e 'print encode_base64("username\0username\0password");'
    debian:~# perl -MMIME::Base64 -e 'print encode_base64("neo\0neo\0chen");'
    			
    220 mail.example.net ESMTP Postfix (Debian/GNU)
    ehlo netkiller
    250-mail.example.net
    250-PIPELINING
    250-SIZE 10240000
    250-ETRN
    250-STARTTLS
    250-AUTH LOGIN PLAIN DIGEST-MD5 CRAM-MD5
    250-AUTH=LOGIN PLAIN DIGEST-MD5 CRAM-MD5
    250 8BITMIME
    auth plain bmVvAG5lbwBjaGVu
    235 Authentication successful
    			

    AUTH LOGIN

    debian:~# perl -MMIME::Base64 -e 'print encode_base64("neo");'
    debian:~# perl -MMIME::Base64 -e 'print encode_base64("chen");'
    
    220 mail.example.net ESMTP Postfix (Debian/GNU)
    ehlo netkiller
    250-mail.example.net
    250-PIPELINING
    250-SIZE 10240000
    250-ETRN
    250-STARTTLS
    250-AUTH LOGIN PLAIN DIGEST-MD5 CRAM-MD5
    250-AUTH=LOGIN PLAIN DIGEST-MD5 CRAM-MD5
    250 8BITMIME
    auth login
    334 VXNlcm5hbWU6
    bmVv
    334 UGFzc3dvcmQ6
    Y2hlbg==
    235 Authentication successful
    			

    CRAM-MD5

    base64(user md5(password))
    试验中...
    			

    DIGEST-MD5

    试验中...
    			

    debian:~# swaks -a LOGIN PLAIN DIGEST-MD5 CRAM-MD5

    debian:/etc/postfix# postfix check
  5. TLS

    输入:STARTTLS

    返回:220 Ready to start TLS

    220 mail.example.net ESMTP Postfix (Debian/GNU)
    ehlo hi
    250-mail.example.net
    250-PIPELINING
    250-SIZE 10240000
    250-ETRN
    250-STARTTLS
    250-AUTH GSSAPI LOGIN PLAIN DIGEST-MD5 CRAM-MD5
    250-AUTH=GSSAPI LOGIN PLAIN DIGEST-MD5 CRAM-MD5
    250 8BITMIME
    STARTTLS
    220 Ready to start TLS 
    			
  6. POP/IMAP

    默认域测试

      debian:/etc/postfix# courierauthtest test chen
      Trying authdaemon...
      Authenticated: module authdaemon
      Home directory: /var/mail
      UID/GID: 105/109
      Maildir: example.net/test/Maildir/
      AUTHADDR=test
      AUTHFULLNAME=test
      OPTIONS=<none>
      			

    虚拟域测试

      debian:/etc/postfix# courierauthtest [email protected] chen
      Trying authdaemon...
      Authenticated: module authdaemon
      Home directory: /var/mail
      UID/GID: 105/109
      Maildir: example.net/chen/maildir/
      [email protected]
      AUTHFULLNAME=chen
      OPTIONS=<none>
      debian:/etc/postfix#
    			

    POP3成功地接收的日志应该是:

    Sep 17 13:46:00 localhost courierpop3login: Connection, ip=[::ffff:192.168.0.254]
    Sep 17 13:46:00 localhost courierpop3login: LOGIN, [email protected], ip=[::ffff:192.168.0.254]
    Sep 17 13:46:00 localhost courierpop3login: LOGOUT, [email protected], ip=[::ffff:192.168.0.254], top=0, retr=0
    			
  7. aliases

    首先使用下面的ldif测试

    dn:uid=neo,ou=postfix,dc=example,dc=net
    uid:neo
    cn:test
    sn:test
    mail:neo
    uidnumber:1001
    gidnumber:1001
    mailhost:mail.example.net
    homedirectory:/var/mail/
    mailbox:example.net/neo/Maildir/
    quota:200000000s,20000c
    userpassword:{crypt}$1$8E.vtK6o$7JdJ6dpTwaLU7x8X2FKwc1
    #clearPassword:chen
    AccountStatus:true
    objectclass:postfixAccount
    objectclass:person
    				

    增加maildrop:[email protected]属性,在测试

    dn:uid=neo,ou=postfix,dc=example,dc=net
    uid:neo
    cn:test
    sn:test
    mail:neo
    uidnumber:1001
    gidnumber:1001
    mailhost:mail.example.net
    homedirectory:/var/mail/
    mailbox:example.net/neo/Maildir/
    quota:200000000s,20000c
    maildrop:[email protected]
    userpassword:{crypt}$1$8E.vtK6o$7JdJ6dpTwaLU7x8X2FKwc1
    #clearPassword:chen
    AccountStatus:true
    objectclass:postfixAccount
    objectclass:person
    				

    mail日志

    Sep 18 07:15:53 localhost postfix/smtpd[13373]: connect from unknown[192.168.0.254]
    Sep 18 07:15:54 localhost postfix/smtpd[13373]: 055774A0DF0: client=unknown[192.168.0.254], sasl_method=LOGIN, [email protected]
    Sep 18 07:15:54 localhost postfix/cleanup[13375]: 055774A0DF0: message-id=<[email protected]>
    Sep 18 07:15:54 localhost postfix/qmgr[13372]: 055774A0DF0: from=<[email protected]>, size=551, nrcpt=1 (queue active)
    Sep 18 07:15:54 localhost postfix/smtpd[13373]: disconnect from unknown[192.168.0.254]
    Sep 18 07:15:59 localhost postfix/smtp[13376]: 055774A0DF0: to=<[email protected]>, orig_to=<[email protected]>, relay=mail.9812.net[202.105.113.174], delay=5, status=sent (250 Ok: queued as C2379225DE7)
    Sep 18 07:15:59 localhost postfix/qmgr[13372]: 055774A0DF0: removed
    				

    这是发往[email protected]的邮件将被转发到[email protected]

    Note

    使用Outlook,Foxmail或debian:/etc/postfix# mail [email protected] < /etc/fstab

  8. spam 测试

    注意:Hits值的变化

    [root@as3 postfix]# tail -f /var/log/maillog|grep [email protected]|grep Hits
    Oct 11 17:36:23 linuxas3 amavis[29336]: (29336-10) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.792
    Oct 11 17:36:23 linuxas3 amavis[29368]: (29368-01) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.793
    Oct 11 17:36:24 linuxas3 amavis[29355]: (29355-09) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.794
    Oct 11 17:36:24 linuxas3 amavis[29372]: (29372-01) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.796
    Oct 11 17:36:25 linuxas3 amavis[29373]: (29373-01) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.797
    Oct 11 17:36:25 linuxas3 amavis[29355]: (29355-10) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.798
    Oct 11 17:36:26 linuxas3 amavis[29372]: (29372-02) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.799
    Oct 11 17:36:27 linuxas3 amavis[29373]: (29373-02) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.8
    Oct 11 17:36:27 linuxas3 amavis[29368]: (29368-02) Passed, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, Hits: -2.802