Centos7+postfix+dovecot for Messaging
When it comes to mail systems, there are many, such as Microsoft's Exchange, Office365, IBM Lotus, and the mainstream third-party messaging system. Of course, these are fees, if for small environment use, can use Linux under the deployment of Postfix+dovecot to achieve mail transceiver, of course, there are many services under Linux to achieve mail delivery, today we mainly introduce the centos7+postfix+ Dovecot to send and receive mail, specifically see below:
First of all, install the CENTOS7, after installation, we need to configure some of the system settings;
1.selinux off, sed–i ' s/enforcing/disabled/g '/etc/selinux/config2. firewall-cmd–add-port= ' 110/tcp ' –permanent firewall-cmd–add-port= ' 25/tcp ' –permanent
When you're ready, check the system version first.
Cat/etc/redhat-release
650) this.width=650; "title=" clip_image001 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image001" src= "http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVCWADl94AABCc_ZnweY389.png" height= "/>"
Centos7 is a self-postfix service, so we don't have to install it separately;
Rpm–qa | grep postfix
650) this.width=650; "title=" clip_image002 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image002" src= "http://s3.51cto.com/wyfs02/M00/8B/DA/wKiom1haVCagbZtIAABH-7KzSrA700.png" height= "/>"
We found that the system comes with a postfix service, so we don't have to install
Postfix 2.10.1-6.el7.x86_64
Then that is to say postfix basic configuration, of course, postfix configuration is very much, we do not introduce more, first introduce the basic configuration of sending mail
We first check the default configuration of the default postfix by taking a look at those that need to be modified
Grep-v ' ^# '/etc/postfix/main.cf | Grep-v ' ^$ '
650) this.width=650; "title=" clip_image003 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image003" src= "http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVCfzYl91AAIwE3uDors768.png" height= "413"/>
Vim/etc/postfix/main.cf
650) this.width=650; "title=" clip_image004 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image004" src= "Http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVCihozu9AAGNuixyTRM212.png" height= "376"/>
Myhostname =pfx.ixmsoft.com #定义主机名mydomain =ixmsoft.com #定义域名myorigin = $mydomain #定义组织域
650) this.width=650; "title=" clip_image005 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image005" src= "Http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVCrTcUdIAAFU70Sfk1g090.png" height= "359"/>
Inet_interfaces =all Define network region Inet_portocols =all Definition Protocol
650) this.width=650; "title=" clip_image006 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image006" src= "Http://s3.51cto.com/wyfs02/M01/8B/D6/wKioL1haVCuSM8vTAAH-nV5KWVc469.png" height= "406"/>
We need to add a $mydomain after the value of mydestination, if not added, the recipient's address will be a problem, if added, the user will send a message directly [email protected]
650) this.width=650; "title=" clip_image007 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image007" src= "http://s3.51cto.com/wyfs02/M02/8B/DA/wKiom1haVCyiaob9AAKBbOu750U419.png" height= "392"/>
Uncomment #local_recipient_maps =
650) this.width=650; "title=" clip_image008 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image008" src= "Http://s3.51cto.com/wyfs02/M00/8B/DA/wKiom1haVC6hPd4qAAGvaAq8CVA750.png" height= "339"/>
Grep-v ' ^# '/etc/postfix/main.cf | Grep-v ' ^$ '
After modifying the Save exit, we view the reverse configuration
650) this.width=650; "title=" clip_image009 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image009" src= "http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVDKjrVG-AAHu8ItOdvI505.png" height= "413"/>
After saving the exit, we start the Postfix service and view the port status,
Systemctl start Postfixsystem Enable Postfixnetstat–anlpt
650) this.width=650; "title=" clip_image010 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image010" src= "Http://s3.51cto.com/wyfs02/M00/8B/DA/wKiom1haVDPCOLtoAACtNJGcLaU292.png" height= "127"/>
Next we install the Dovecot service, which mainly provides POP3, IMAP services
Yum Install Dovecot
650) this.width=650; "title=" clip_image011 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image011" src= "Http://s3.51cto.com/wyfs02/M00/8B/D6/wKioL1haVDTz_FD0AAEXlgtF_Us737.png" height= "280"/>
Installation Complete
650) this.width=650; "title=" clip_image012 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image012" src= "Http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVDbSaay0AAECkBuFZAs829.png" height= "325"/>
Next we look at the default configuration file for Dovecot
We see that the following include can contain the configuration file path strength, the *.conf file in this path will take effect
650) this.width=650; "title=" clip_image013 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image013" src= "http://s3.51cto.com/wyfs02/M02/8B/DA/wKiom1haVDfRQit3AAI7rbXsHpw564.png" height= "475"/>
We enable protocols for the following protocols
protocols = IMAP POP3 LMTP enable port monitoring Listen = *,::
650) this.width=650; "title=" clip_image014 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "border=" 0 "alt=" clip_ image014 "src=" http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVDnAe-1jAAK44RCnGHk732.png "height=" 446 "/>
Save exit
Grep-v ' ^# '/etc/dovecot/dovecot.conf | Grep-v ' ^$ '
650) this.width=650; "title=" clip_image015 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image015" src= "Http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVDrROuE2AACm4_Ii16Y618.png" height= "162"/>
Vim/etc/dovecot/conf.d/10-auth.confdisable_plaintext_auth = No
650) this.width=650; "title=" clip_image016 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image016" src= "Http://s3.51cto.com/wyfs02/M02/8B/DA/wKiom1haVDvxkOvlAAGnokPgJos070.png" height= "257"/>
Auth_mechanisms = Plain Login!include auth-system.conf.ext
650) this.width=650; "title=" clip_image017 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image017" src= "Http://s3.51cto.com/wyfs02/M02/8B/DA/wKiom1haVD-yRtZ7AAHupUIAyQQ218.png" height= "459"/>
Save exit
Grep-v ' ^# '/etc/dovecot/conf.d/10-auth.conf | Grep-v ' ^$ '
650) this.width=650; "title=" clip_image018 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image018" src= "http://s3.51cto.com/wyfs02/M00/8B/DA/wKiom1haVECj70jHAABnE4c_NoY562.png" height= "/>"
Disable SSL authentication, as follows:
Of course, you can not cancel the SSL, according to their own environment to set
Vim/etc/dovecot/conf.d/10-ssl.confssl = No
650) this.width=650; "title=" clip_image019 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image019" src= "Http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVELCddmPAAJHnReIokc124.png" height= "347"/>
Enable the Dovecot log, as follows:
vim/etc/dovecot/conf.d/10-logging.conf Add info_log_path =/var/log/dovecot_info.logdebug_log_path =/var/log/dovecot _debug.log
650) this.width=650; "title=" clip_image020 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image020" src= "Http://s3.51cto.com/wyfs02/M01/8B/D6/wKioL1haVEODaMqeAAHGtKB0wys655.png" height= "376"/>
Then start the service
Systemctl start Dovecotsystemctl Enable Dovecot
We've seen 110, 143 are already listening.
650) this.width=650; "title=" clip_image021 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image021" src= "Http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVETClRd-AAE5T5Zz7io935.png" height= "204"/>
Next we create a test user
Useradd zspasswd ZS
Then enter the old and new password
650) this.width=650; "title=" clip_image022 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image022" src= "Http://s3.51cto.com/wyfs02/M00/8B/D6/wKioL1haVEWB474-AACd8DtlTcA573.png" height= "111"/>
And then we start testing.
[[Email protected] ~]# telnet localhost 110Trying:: 1...Connected to localhost. Escape character is ' ^] '. +ok dovecot ready.user zs+okpass 123456-err [sys/temp] Internal error occurred. Refer to server log for more information. Connection closed by foreign host.
650) this.width=650; "title=" clip_image023 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image023" src= "Http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVEbieyodAACNhCQAhJU610.png" height= "143"/>
We look at log
[[Email protected] ~]# tail -f /var/log/maillogdec 21 00:37:58 pfx postfix/postfix-script[9570]: stopping the Postfix mail systemDec 21 00:37:58 pfx postfix/master[9553]: terminating on signal 15dec 21 00:38:01 pfx postfix/postfix-script[9654]: starting the postfix mail systemdec 21 00:38:01 pfx postfix/master[9656]: daemon started -- Version 2.10.1, configuration /etc/postfixdec 21 00:38:08 pfx postfix/smtpd [9661]: warning: hostname bogon does not resolve to address 192.168.5.20: name or service not knowndec 21 00:38:08 pfx postfix/smtpd[9661]: connect from unknown[192.168.5.20]dec 21 00:38:20 pfx Postfix/smtpd[9661]: lost connection after connect from unknown[192.168.5.20]dec 21 00:38:20 pfx Postfix/smtpd[9661]: disconnect from unknown[192.168.5.20]dec 21 00:55:46 pfx  DOVECOT: POP3 (ZS): error: user zs: initialization failed: namespace ': mail storage autodetection failed with home=/home/zsdec 21 00:55:46 PFX DOVECOT: POP3 (ZS): error: invalid user settings. refer to server log for more information.
650) this.width=650; "title=" clip_image024 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image024" src= "http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVEfzaJtEAAEqYyMSprE133.png" height= "123"/>
We switched to just the user
Su–zs then creates the INBOX directory for user ZS, Mkdir-p ~/mail/.imap/inbox
650) this.width=650; "title=" clip_image025 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image025" src= "http://s3.51cto.com/wyfs02/M02/8B/DA/wKiom1haVEiwOTz3AABJgYXyFBs515.png" height= "/>"
And then try it again.
[[Email protected] ~]# telnet localhost 110Trying:: 1...Connected to localhost. Escape character is ' ^] '. +ok dovecot ready.user zs+okpass 123456+ok logged in.
650) this.width=650; "title=" clip_image026 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image026" src= "Http://s3.51cto.com/wyfs02/M02/8B/D6/wKioL1haVEjjr9d8AAB8fUIwcEs964.png" height= "171"/>
Test Send mail
[[Email protected]/]# telnet localhost 25Trying:: 1...Connected to localhost. Escape character is ' ^] '. mail.ixmsoft.com ESMTP postfixmail from:[email protected]250 2.1.0 okrcpt to:[email protected ]250 2.1.5 Okdata354 End data with <cr><lf>.<cr><lf>this is Test mail.250 2.0.0 ok:queued as A702 d400fc14quit221 2.0.0 byeconnection closed by foreign host.
650) this.width=650; "title=" clip_image027 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image027" src= "Http://s3.51cto.com/wyfs02/M00/8B/DA/wKiom1haVErxQtGMAAD3zgfXgyY643.png" height= "284"/>
We view Mail
[[Email protected]/]# telnet localhost 110Trying:: 1...Connected to localhost. Escape character is ' ^] '. +ok dovecot ready.user ls+okpass 123456+ok logged in.list+ok 1 messages:1 409.
650) this.width=650; "title=" clip_image028 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image028" src= "Http://s3.51cto.com/wyfs02/M00/8B/D6/wKioL1haVEqjEWyUAACJwLUR4nU588.png" height= "235"/>
We need to create a directory every time, more trouble, we can not use the script it
To set up a mail hosting directory:
vim/etc/dovecot/conf.d/10-mail.conf Remove the following comment mail_location = mbox:~/mail:inbox=/var/mail/%u #指定邮件的位置
650) this.width=650; "title=" clip_image029 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt = "clip_image029" src= "Http://s3.51cto.com/wyfs02/M01/8B/D6/wKioL1haVEvSLV4hAAGmYe0lVew359.png" height= "354"/>
Restart the Dovecot service systemctl Restart Dovecot Modify the Create User template file to automatically generate the mail directory when the user creates it vim/etc/skel/.bash_profile add a profile, if[!-D ~/mail /.imap/inbox]; Thenmkdir-p ~/mail/.imap/inboxfi Note: If it is a copy, it is best to perform the following encoding format before saving the rollout: Set Format=unix or you can download the attachment, replace the current configuration file
650) this.width=650; "title=" clip_image030 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "border=" 0 "alt=" clip_ image030 "src=" http://s3.51cto.com/wyfs02/M01/8B/DA/wKiom1haVEzyhC0zAACwgGqX7oE738.png "height="/>
After you save the exit, execute it for quick entry.
source. bash_profile
Next we need to create a test user, after the user is created, after using the new user login, will automatically create the relevant directory, and then directly can use the mailbox, we can also use Outlook or other means of testing the message, again do not test;
If you want to have external and internal mail, you need to publish the server 110, 25 to the external network, and then the external domain name provider configuration MX record resolution and a record resolution, so that the mail can be returned.
We finally used Foxmail to test the intranet;
We configure two accounts, ZS, LS users to send and receive e-mail tests:
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8B/DA/wKiom1haWDGSAxF8AABfPfIO6Lo009.jpg-wh_500x0-wm_3 -wmp_4-s_366338918.jpg "style=" Float:none; "title=" 1.jpg "alt=" Wkiom1hawdgsaxf8aabfpfio6lo009.jpg-wh_50 "/>
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8B/D6/wKioL1haWDGhshNFAAAbVwKhwPQ287.jpg-wh_500x0-wm_3 -wmp_4-s_3083216478.jpg "style=" Float:none; "title=" 2.jpg "alt=" Wkiol1hawdghshnfaaabvwkhwpq287.jpg-wh_50 "/>
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8B/DA/wKiom1haWDPAVCd8AADPUco5RlI259.jpg-wh_500x0-wm_3 -wmp_4-s_3762451218.jpg "style=" Float:none; "title=" 3.jpg "alt=" Wkiom1hawdpavcd8aadpuco5rli259.jpg-wh_50 "/>
We'll add another LS account.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8B/D6/wKioL1haWDPj9gBJAADh1Qv4xD4654.jpg-wh_500x0-wm_3 -wmp_4-s_1869323976.jpg "style=" Float:none; "title=" 4.jpg "alt=" Wkiol1hawdpj9gbjaadh1qv4xd4654.jpg-wh_50 "/>
Use ZS to send an e-mail to LS
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/DA/wKiom1haWDThOUWuAABoIc6kynQ403.jpg-wh_500x0-wm_3 -wmp_4-s_2659717844.jpg "style=" Float:none; "title=" 5.jpg "alt=" Wkiom1hawdthouwuaaboic6kynq403.jpg-wh_50 "/>
ZS received the mail.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8B/D7/wKioL1haWDXglw68AACDhgAy3YY150.jpg-wh_500x0-wm_3 -wmp_4-s_272738300.jpg "style=" Float:none; "title=" 6.jpg "alt=" Wkiol1hawdxglw68aacdhgay3yy150.jpg-wh_50 "/>
LS also received an e-mail.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8B/D7/wKioL1haWDWTLkTqAACOvBCbkC8438.jpg-wh_500x0-wm_3 -wmp_4-s_944108726.jpg "style=" Float:none; "title=" 7.jpg "alt=" Wkiol1hawdwtlktqaacovbcbkc8438.jpg-wh_50 "/>
This article from "Gao Wenrong" blog, declined reprint!
Centos7+postfix+dovecot for Messaging