本章測試

測試步驟

  1. check

    debian:~# postfix check
    			
  2. postconf

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

    # mail chen@example.net < /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=<20040917053935.487EE49BA3F@mail.example.net>
    Sep 17 13:39:35 localhost postfix/qmgr[8682]: 487EE49BA3F: from=<chen@example.net>, size=584, nrcpt=1 (queue active)
    Sep 17 13:39:35 localhost postfix/virtual[8686]: 487EE49BA3F: to=<chen@example.net>, 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 chen@example.net chen
      Trying authdaemon...
      Authenticated: module authdaemon
      Home directory: /var/mail
      UID/GID: 105/109
      Maildir: example.net/chen/maildir/
      AUTHADDR=chen@example.net
      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, user=chen@example.net, ip=[::ffff:192.168.0.254]
    Sep 17 13:46:00 localhost courierpop3login: LOGOUT, user=chen@example.net, 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:openunix@163.com屬性,在測試

    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:openunix@163.com
    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, sasl_username=test@example.net
    Sep 18 07:15:54 localhost postfix/cleanup[13375]: 055774A0DF0: message-id=<20040917231554.055774A0DF0@mail.example.net>
    Sep 18 07:15:54 localhost postfix/qmgr[13372]: 055774A0DF0: from=<test@example.net>, 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=<openunix@163.com>, orig_to=<neo@example.net>, 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
    				

    這是發往neo@example.net的郵件將被轉發到openunix@163.com

    Note

    使用Outlook,Foxmail或debian:/etc/postfix# mail neo@example.net < /etc/fstab

  8. spam 測試

    注意:Hits值的變化

    [root@as3 postfix]# tail -f /var/log/maillog|grep root@mail.example.net|grep Hits
    Oct 11 17:36:23 linuxas3 amavis[29336]: (29336-10) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184602.A04784A0D65@mail.example.net>, Hits: -2.792
    Oct 11 17:36:23 linuxas3 amavis[29368]: (29368-01) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184602.533D14A0D61@mail.example.net>, Hits: -2.793
    Oct 11 17:36:24 linuxas3 amavis[29355]: (29355-09) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184602.B3B7C4A0D66@mail.example.net>, Hits: -2.794
    Oct 11 17:36:24 linuxas3 amavis[29372]: (29372-01) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184602.C47CE4A0D67@mail.example.net>, Hits: -2.796
    Oct 11 17:36:25 linuxas3 amavis[29373]: (29373-01) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184603.0979D4A0D69@mail.example.net>, Hits: -2.797
    Oct 11 17:36:25 linuxas3 amavis[29355]: (29355-10) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184603.3D3054A0D6D@mail.example.net>, Hits: -2.798
    Oct 11 17:36:26 linuxas3 amavis[29372]: (29372-02) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184603.50C8F4A0D6D@mail.example.net>, Hits: -2.799
    Oct 11 17:36:27 linuxas3 amavis[29373]: (29373-02) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184603.61BC14A0D6D@mail.example.net>, Hits: -2.8
    Oct 11 17:36:27 linuxas3 amavis[29368]: (29368-02) Passed, <root@mail.example.net> -> <neo@example.net>, Message-ID: <20041010184603.2BF4F4A0D69@mail.example.net>, Hits: -2.802