Test postfix + cyrus-imap + cyrus-sasl in linuxas5.5

Source: Internet
Author: User
Tags imap starttls
In linuxas5.5, test postfix + cyrus-imap + cyrus-sasl -- Linux Enterprise Application-Linux server application information. For details, see the following. Test environment:

Cat/proc/version
Linux version 2.6.18-194. el5xen

[Root @ mail ~] # Rpm-qa | grep sasl
Cyrus-sasl-plain-2.1.22-5.el5_4.3
Cyrus-sasl-lib-2.1.22-5.el5_4.3
Cyrus-sasl-md5-2.1.22-5.el5_4.3
Cyrus-sasl-2.1.22-5.el5_4.3
Cyrus-sasl-devel-2.1.22-5.el5_4.3

[Root @ mail ~] # Rpm-qa | grep postfix
Postfix-2.3.3-2.1.el5_2

[Root @ mail ~] # Rpm-qa | grep cyrus-imap
Cyrus-imapd-utils-2.3.7-7.el5_4.3
Cyrus-imapd-perl-2.3.7-7.el5_4.3
Cyrus-imapd-2.3.7-7.el5_4.3

All the above versions are included in linux as 5.5. Remember to delete sendmail.



Service Startup command:

Service saslauthd start

Chkconfig -- level 0123456 saslauthd on

Service postfix start

Chkconfig -- level 0123456 postfix on

Service cyrus-imapd start

Chkconfig -- level 0123456 cyrus-imapd on

Configure cyrus-imap to locally verify shadow

[Root @ mail ~] # Saslauthd-v # view support for cyrus-sasl Verification
Saslauthd 2.1.22
Authentication mechanisms: getpwent implements os5 pam rimap shadow ldap

[Root @ mail ~] # Saslauthd-a shadow # select a Verification Method

[Root @ mail ~] # Ps-ef | grep saslauthd
Root 2794 1 0 :05? 00:00:00/usr/sbin/saslauthd-m/var/run/saslauthd-a shadow
Root 2795 2794 0? 00:00:00/usr/sbin/saslauthd-m/var/run/saslauthd-a shadow
Root 2796 2794 0? 00:00:00/usr/sbin/saslauthd-m/var/run/saslauthd-a shadow
Root 2797 2794 0? 00:00:00/usr/sbin/saslauthd-m/var/run/saslauthd-a shadow
Root 2798 2794 0? 00:00:00/usr/sbin/saslauthd-m/var/run/saslauthd-a shadow
Root 3656 3594 0 00:00:00 pts/1 grep saslauthd

Configure the imap Server

[Root @ mail ~] # Vi/etc/imapd. conf

Configdirectory:/var/lib/imap
Partition-default:/var/spool/imap
Admins: cyrus
Sievedir:/var/lib/imap/sieve
Sendmail:/usr/sbin/sendmail
Hashimapspool: true
Sasl_pwcheck_method: saslauthd
Sasl_mech_list: PLAIN
Tls_cert_file:/etc/pki/cyrus-imapd/cyrus-imapd.pem
Tls_key_file:/etc/pki/cyrus-imapd/cyrus-imapd.pem
Tls_ca_file:/etc/pki/tls/certs/ca-bundle.crt

Cyrus imap uses syslog in 4.3BSD format,

Vi/etc/syslog and add the following two lines

Local6.debug/var/log/imapd. log
Auth. debug/var/log/auth. log

Generate two blank log files

Touch/var/log/imapd. log/var/log/auth. log

Create a configuration directory and set it according to the preceding configuration file.

Cd/var
Mkdir imap
Chown cyrus mail

Chgrp mail

Chmod 750 mail

Cd/var/spool
Mkdir imap
Chown cyrus mail

Chgrp mail

Chmod 750 imap
Cd/usr
Mkdir sieve
Chown cyrus sieve
Chgrp mail sieve
Chmod 750 sieve

Cd/var/imap
Chattr + S user quota user/* quota /*
Chattr + S/var/spool/imap /*

If you are using senmail as the MTA, You need to execute the following sentence:

Chattr + S/var/spool/mqueue

Edit the/etc/services file. If the file does not contain the following content, add the following lines:

POP3. 110/tcp
Imap 143/tcp
Imsp 406/tcp
Acap 674/tcp
Imaps 993/tcp
Pop3s 995/tcp
Kpop 1109/tcp
Sieve 2000/tcp
Lmtp 2003/tcp
Fud 4201/udp

View/etc/inetd. conf or/etc/xinetd. whether the imap, imaps, pop3, pop3s, kpop, lmtp, and sieve contents exist in the d directory. If yes, delete the corresponding content.

Restart the inet or xinet Process

/Etc/rc. d/init. d/inet resart

Or

/Etc/rc. d/init. d/xinet restart

Configure the main process file: there is a reference configuration file under the master/config directory under the original code file. We select the most basic Installation File

Cp master/conf/small. conf/etc/cyrus. conf

If your cyrus imap has added support for openssl during compilation, you can use normal. conf.
Cp master/conf/normal. conf/etc/cyrus. conf

Edit/etc/cyrus. conf
Set

Lmtpunix cmd = 'lmtpd 'listen ='/var/imap/socket/lmtp 'prefork = 0

Replace

Lmtpunix cmd = 'lmtpd 'listen ='/var/imap/socket/lmtp 'prefork = 1

[Root @ mail ~] # Service cyrus-imapd restart
Shutting down cyrus-imapd: [OK]
Export the cyrus-imapd Database: [OK]
Import the cyrus-imapd Database: [OK]
Start cyrus-imapd: [OK]
[[Root @ mail ~] # Telnet to localhost 110
Trying 127.0.0.1...
Connected to localhost. localdomain (127.0.0.1 ).
Escape character is '^]'.
+ OK mail.local.vic-cn.com Cyrus POP3 v2.3.7-Invoca-RPM-2.3.7-7.el5_4.3 server ready

Quit
+ OK
Connection closed by foreign host.

Create mailbox

[Root @ mail ~] # Id cyrus

Uid = 76 (cyrus) gid = 12 (mail) groups = 12 (mail), 76 (saslauth) context = root: system_r: unconfined_t: SystemLow-SystemHigh
[Root @ mail ~] # Su cyrus

Bash-3.2 $ cyradm-u cyrus localhost
IMAP Password:
Localhost. localdomain> help # cyrus-imap Management Interface
Authenticate, login, auth authenticate to server
Chdir, cd change current directory
Createmailbox, create, cm create mailbox
Deleteaclmailbox, deleteacl, dam remove ACLs from mailbox
Deletemailbox, delete, dm delete mailbox
Disconnect, disc disconnect from current server
Exit, quit exit cyradm
Help ,? Show commands
Info display mailbox/server metadata
Listacl, lam, listaclmailbox list ACLs on mailbox
Listmailbox, lm list mailboxes
Listquota, SCSI list quotas on specified root
Listquotaroot, lqr, lqm show quota roots and quotas for mailbox
Mboxcfg, mboxconfig configure mailbox
Reconstruct mailbox (if supported)
Renamemailbox, rename, renm rename (and optionally relocate) mailbox
Server, servername, connect show current server or connect to server
Setaclmailbox, sam, setacl set ACLs on mailbox
Setinfo set server metadata
Setquota, sq set quota on mailbox or resource
Subscribe, sub subscribe to a mailbox
Unsubscribe, unsub unsubscribe from a mailbox
Version, ver display version info of current server
Xfermailbox, xfer transfer (relocate) a mailbox to a different server
Localhost. localdomain> cm user. test
Localhost. localdomain> sq user. test 100000
Quota: 100000
Localhost. localdomain> lm
User. mail (\ HasNoChildren) user. test (\ HasNoChildren)
User. mis (\ HasNoChildren) user. wiz (\ HasNoChildren)
User. postmaste (\ HasNoChildren)
Localhost. localdomain> SCSI user. test
STORAGE 0/100000 (0%)

After user. test is created, only the user has full control over the mailbox. Even the Administrator cyrus has no permission.
To delete the mailbox, you must grant the Administrator full permission (the setacl command). You can use the listacl command to view the user's access permissions to the mailbox.

Localhost. localdomain> listacl user. test
Test lrswipkxtecda
Localhost. localdomain> dm user. test # delete a mailbox
Deletemailbox: Permission denied
Localhost. localdomain> setacl user. test cyrus all
Localhost. localdomain> dm user. test
Localhost. localdomain> cm user. test
Localhost. localdomain> sq user. test 100000
Quota: 100000
Localhost. localdomain> exit
Bash-3.2 $ exit
Exit

[Root @ mail ~] # Ls/var/spool/imap/t/user # the corresponding directory is generated after the mailbox is created.
Test
[Root @ mail ~] # Useradd test-g mail-s/sbin/nologin

[Root @ mail ~] # Id test
Uid = 502 (test) gid = 12 (mail) groups = 12 (mail) context = root: system_r: unconfined_t: SystemLow-SystemHigh
[Root @ mail ~] # Imtest-m login-a test localhost # test imap test user logon
S: * OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL + ID STARTTLS] mail.test.com Cyrus IMAP4 v2.3.7-Invoca-RPM-2.3.7-7.el5_4.3 server ready
C: C01 CAPABILITY
S: * CAPABILITY IMAP4 specify LITERAL + id starttls acl rights = kxte quota mailbox-specify namespace uidplus specify unselect children multiappend binary sort = modseq thread = orderedsubject thread = REFERENCES specify CATENATE CONDSTORE IDLE LISTEXT LIST- SUBSCRIBED X-NETSCAPE (URLAUTH)
S: C01 OK Completed
Please enter your password:
C: L01 LOGIN test {4}
S: + go ahead
C:
S: l01 OK [CAPABILITY IMAP4 using LITERAL + ID using ACL RIGHTS = kxte QUOTA MAILBOX-Your NAMESPACE UIDPLUS using UNSELECT CHILDREN MULTIAPPEND BINARY SORT = MODSEQ THREAD = ORDEREDSUBJECT THREAD = REFERENCES using CATENATE CONDSTORE IDLE LISTEXT LIST-SUBSCRIBED X-NETSCAPE (URLAUTH] User logged in)
Authenticated.
Security strength factor: 0
. Logout
* Bye logout received
. OK Completed
Connection closed.

Configure postfix

[Root @ mail/] # cat./usr/lib/sasl2/smtpd. conf
Pwcheck_method: saslauthd
Mech_list: plain login

[Root @ mail ~] # Vi/etc/postfix/main. cf

[Root @ mail ~] #

[Root @ mail ~] # Postconf-n # configuration result of main. cf
Alias_database = hash:/etc/postfix/aliases
Alias_maps = hash:/etc/postfix/aliases
Broken_sasl_auth_clients = yes
Command_directory =/usr/sbin
Config_directory =/etc/postfix
Daemon_directory =/usr/libexec/postfix
Debug_peer_level = 2
Html_directory = no
Inet_interfaces = all
Mail_owner = postfix
Mail_spool_directory =/var/spool/imap
Mailbox_command =/usr/bin/procmail-a-o-a $ DOMAIN-d $ LOGNAME
Mailbox_transport = lmtp: unix:/var/lib/imap/socket/lmtp
Mailq_path =/usr/bin/mailq. postfix
Manpage_directory =/usr/share/man
Mydestination = $ myhostname, localhost, $ mydomain
Mydomain = test.com
Myhostname = test.com
Mynetworks_style = class
Myorigin = $ mydomain
Newaliases_path =/usr/bin/newaliases. postfix
Queue_directory =/var/spool/postfix
Readme_directory =/usr/share/doc/postfix-2.3.3/README_FILES
Relay_domains = $ mydestination
Sample_directory =/usr/share/doc/postfixed-2.3.3/samples
Sendmail_path =/usr/sbin/sendmail. postfix
Setgid_group = postdrop
Smtpd_client_restrictions = permit_sasl_authenticated
Smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
Smtpd_sasl_auth_enable = yes
Smtpd_sasl_local_domain =''
Smtpd_sasl_security_options = noanonymous
Unknown_local_recipient_reject_code = 550



[Root @ mail ~] # Service saslauthd restart
Stop saslauthd: [OK]
Start saslauthd: [OK]
[Root @ mail ~] # Service cyrus-imapd restart
Shutting down cyrus-imapd: [OK]
Export the cyrus-imapd Database: [OK]
Import the cyrus-imapd Database: [OK]
Start cyrus-imapd: [OK]
[Root @ mail ~] # Service postfix restart
Disable postfix: [OK]
Start postfix: [OK]
[Root @ mail ~] # Telnet localhost 25
Trying 127.0.0.1...
Connected to localhost. localdomain (127.0.0.1 ).
Escape character is '^]'.
220 mail.test.com ESMTP Postfix
Helo microsoft.com
250 mail.test.com
Quit
221 2.0.0 Bye
Connection closed by foreign host.
[Root @ mail ~] #

For more information about the test deficiencies
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.