Xây Dựng Mail Server Postfix Và Quản Lý Email Bằng Php Mysql
-
Upload
nguyentruong -
Category
Documents
-
view
237 -
download
11
description
Transcript of Xây Dựng Mail Server Postfix Và Quản Lý Email Bằng Php Mysql
-
17/6/2015 Xydngmailserverpostfixvqunlemailbngphpmysql
http://thuonghieuweb.com/content/xaydungmailserverpostfixvaquanlyemailbangphpmysql.html 1/6
Trangch Thitkweb ngktnmin Dchvhosting Chothumych Quntrnidung Chiaskinthc Htr
Xydngmailserverpostfixvqunlemailbngphpmysqlupdatedon20150113
Trcythuonghieuwebcmtbivithngdntrinkhaimailserverngintrnhiuhnhlinux,sdngccusercahiuhnhlmemailaccount.Naythuonghieuwebtiptcphttrinhngnyvchiascchcthqunlcnhiutnminnhiuemailtrnmtserver.
tmhiutgcnngnccbncththamkhobivitnybitcchhnhthnhmtmailservernguynthylnhthno,tuynhinnumunhctheokiustepbystepthvncthbtungayvibivitnyvchukhtheongtngbccabivitlxong.
Chunb:
BncncmtmychhocmtVPScithiuhnhCentos5.xtrlnGinhlbnbitvwebservervcitsnccngdngapache,php,mysqlvphpmyadminlnservernynunhbnchacccngdngny,hythamkhobivitnycitchng.
Bc1:Thitlphostnameutinchngtacnkimtrahostnamecamychvhostnamenysdngchomtsthitlphthngsauny.kimtrahostnamecalinux,chngtadnglnhsau
#hostnamef
thayihostname,chngtachnhsadngHOSTNAMEtrongfile/etc/sysconfig/network.
Ngoiratacngcnnhnghahostnamegnviipcamychnytrongfile/etc/hosts.Vicnhnghahostnametrongfile/etc/hostssgipservercthdindchcchostnamedngtestmkhngcnphinhnghaccbnghitrnDNSserver.
Bc2:Kimtravupdateyum,repo
Trchtchngtaupdatecngccityumbnglnhsau
#yumyupdate
Ngoirachngtacngcnkimtratrongrepocahiuhnhcdnglnhexclude=postfix*nhhnhdiyhaychabnglnhsau:
#vi/etc/yum.repos.d/CentOSBase.repo
Nuchacththmdngnyvoqutrnhdownloadvcitslybnpostfixhtrmysql.
Xemchitit...
THUHOSTINGTNGWEBSITE
1Glutr
30Glulng
PHP/MySQL
Minphthitkwebsite
120.000/thngEMAILCHODOANHNGHIP
Khnggiihnshmth
SdngIPquctring
Khngbblacklist
Khnggiihndunglngmail
200.000/thngQUNGCOTUYNDNG
CngtycphntruynthngsVDATAcn tuyn gp 2 coder PHP. Yu cubit v PHP,MySQL.u tin cc bnbit v h thng, phn cng, h iuhnh linux, email services, chm ch,cnc,trungthc.Lngtheomcp ng cng vic. Np h s quaemail [email protected]. Tm hiuthng tin qua s in thoi 0989848886.
Htrtrctuynti hocgihotline0989848886
-
17/6/2015 Xydngmailserverpostfixvqunlemailbngphpmysql
http://thuonghieuweb.com/content/xaydungmailserverpostfixvaquanlyemailbangphpmysql.html 2/6
Bc3:Kimtravcitccgimysqldevel,cyrussasl,dovecot,postfix
Khibncitmysqlcththiumtsgiphnmmcnthitktnipostfixvimysqllmysqldevelvcyrussaslvvychngtacnkimtrabngcclnhsau
#rpmqa|grepmysql(kimtraxemcccgidchvnoikmvimysqlccit)#rpmqa|grepsasl(kimtraxemgicyrussaslccitcha)#rpmqa|grepdovecot#rpmqa|greppostfix
NuccgitrncthOK,cnnuchacchngtadnglnhsaucitnglotccginy
#yumyinstallmysqlmysqldeveldovecotcyrussasl
Chngtacngcndnglnhsauykimtraxempostfixccitcngmodulemysqlhaycha
#postfixm
NunhnthymodulemysqlthOK,cnnukhngthy,chngtadnglnhyumremovepostfixgbbnpostfixcvcilibnmibnglnhsau
#yumenablerepo=centosplusinstallpostfix
Bc4.Gbccdchvcxungtvtchtkhingchopostfix,dovecot
HiuhnhCentoscsnmtsdchvnhsendmail,exim...chngtacnkimtravttccdchvnyitrnhxungtvipostfixbngcchsau
#servicesendmailstatus#servicesendmailstop#chkconfigsendmailoff
Saubtccdchvmicitbc3ln
#servicemysqlstart#servicedovecotstart#servicepostfixstart#chkconfigmysqlon#chkconfigdovecoton#chkconfigpostfixon
Bc5:tmtkhuchouserrootcacsdliumysql
Bncnlurng,ngaysaukhicitmysql,csdliunycsnmtusercquynticao.luserroot,trngtnviuserrootcahthngnhngkhclcpasswordbngtrng.Vvyphingaylptctmtkhuchousernybnglnhsau:
#mysql_secure_installation
Khithchinlnhtrnbnsnhnc4cuhinhsau:
Setrootpassword?[Y/n](tmtkhuchoroot)Removeanonymoususers?[Y/n](Xabuservdanh)Disallowrootloginremotely?[Y/n](Khngchophprootngnhptxa)Removetestdatabaseandaccesstoit?[Y/n](Xabdatabasetest)
BnnntrliYchoc4cuhitrnbtcclhngbomtcamysql.
Bc6:Todatabasemailserverluccthngsdomain,emailaccounto.
Chngtadnglunuserrootvatmtkhutrnthchincclnhtodatabasevtabletdnglnhnhsau.Hocnubnciphpmyadminthcththaotctodatabasevtabletrngiaodinweb.
#mysqlurootp
-
17/6/2015 Xydngmailserverpostfixvqunlemailbngphpmysql
http://thuonghieuweb.com/content/xaydungmailserverpostfixvaquanlyemailbangphpmysql.html 3/6
saukhigmtkhubnscvokhuvcdnglnhcamysqlvidunhcnhsau:
mysql>
Bnglnh
mysql>CREATEDATABASEmail
tomtdatabasetnlmail.Sautomtusercquynthaotctrndatabasenybnglnhsau:
mysql>USEmailmysql>GRANTSELECT,INSERT,UPDATE,DELETEONmail.*TO"mail_admin"@"localhost"IDENTIFIEDBY"123#abc"mysql>FLUSHPRIVILEGES
Trong123#abclmtkhucausermail_admin.Bnnnghilimtkhunyvsaunsbmhatrongcsdliu,khngcnnhncdngplaintextna.
Lu:cclnhcamysqluphiktthcbngduchmphy()ccthamsinmvmutrnltybin,bncthttndatabase,vuser,mtkhutheothchcamnh,tuynhinnutestchngtanndngthngnhtcctnnytrnhphisainhiuccbcsau.
Bc7:tocctablequnldomainvusero.
Chngtacnto4tableldomains,forwarding,transports,vusers.tableforwardingvtransportdngchoccchcnngmrngsaunycaemailnhforward,relay...Trongbivitnychacpnccchcnngnncthkhngcntocctableny.Chcnctabledomainsvusersl.
mysql>CREATETABLEdomains(domainvarchar(50)NOTNULL,PRIMARYKEY(domain))mysql>CREATETABLEforwardings(sourcevarchar(80)NOTNULL,destinationTEXTNOTNULL,PRIMARYKEY(source))mysql>CREATETABLEtransport(domainvarchar(128)NOTNULLdefault"",transportvarchar(128)NOTNULLdefault"",UNIQUEKEYdomain(domain))mysql>CREATETABLEusers(emailvarchar(80)NOTNULL,passwordvarchar(20)NOTNULL,PRIMARYKEY(email))mysql>exit
Lucclnhtrncththchintrongphpmyadminnuccbncitgidchvny.
Bc8:Thitlpachipchomysqlserver#vi/etc/my.cnf
thmvomtdngnhsau:
bindaddress=127.0.0.1
Ghilivkhinglidchvmysql
#servicemysqlrestart
Bc9:Toccfilecuhnhchopostfix
Chngtacnto4filecuhnhpostfixbitcchqueryvocsdliu,lyraccgitrnhdomain,forwarding,emailaccount...Ccbndownloadc4fileysauuploadlnthmc/etc/postfix/,mravsaccthamsuser,passwordvdbnamenhvatotrn.
Sauthitlppermissionsvownershipchoccfilenybngcclnhsau
#chmodo=/etc/postfix/mysqlvirtual_*.cf#chgrppostfix/etc/postfix/mysqlvirtual_*.cf
cthnhnemail,chngtacntomtuservgroupctnlvmail.Ccvirtualmailboxescaccemailaccountctorasauny,sclutrtrongthmchomecauserny(/home/vmail)
#groupaddg5000vmail#useraddgvmailu5000vmaild/home/vmailm
Bc10:Cuhnhpostfix.
Ccbntifileconfig.shnyv,sauuploadvothmc/etc/postfix/vsadngutincafilechongvihostnamecaccbn,chmodsang755vchyfilentaddccdngtrongconfig.shvofilemain.cfcapostfix.
#vi/etc/postfix/config.sh#chmod755/etc/postfix/config.sh#/etc/postfix/config.sh
Tiptheochngtachnhsafilemaster.cf,thmdngsauvoongiafie,mcInterfacestononPostfix
-
17/6/2015 Xydngmailserverpostfixvqunlemailbngphpmysql
http://thuonghieuweb.com/content/xaydungmailserverpostfixvaquanlyemailbangphpmysql.html 4/6
software
dovecotunixnnpipeflags=DRhuuser=vmail:vmailargv=/usr/libexec/dovecot/deliverf${sender}d${recipient}
Khinglidchvpostfix
#servicepostfixrestart
Bc11:Cuhnhdovecot
Ccbntifilecuhnhdovecot.confmiyv,sauuploadln/etc.Lu,nnbackuplimtbncafiledovecot.confctrckhifilemiln.Mfiledovecot.confravsadngpostmaster_address=postmaster@thuonghieuweb.comvitnmincabn.
Sauto1filedovecotsql.confmcvodatabasenhsau:
#vi/etc/dovecotsql.conf
driver=mysqlconnect=host=127.0.0.1dbname=mailuser=mail_adminpassword=123#abcdefault_pass_scheme=CRYPTpassword_query=SELECTemailasuser,passwordFROMusersWHEREemail="%u"
Gnquyntruycpchofilenynhsau
#chgrpdovecot/etc/dovecotsql.conf#chmodo=/etc/dovecotsql.conf
Khinglidovecot
#servicedovecotrestart
Bc12.Kimtraktqucaccbctrn
Kimtralogmbodchvdovecotchyvkoclig
#tailf/var/log/maillog
Nuc2dngsaulok(xemthmhnhchp):Dovecotv1.0.7startingup:mysql:Connectedto127.0.0.1(mail)
KimtradchvPOP3glnhtelnetlocalhostpop3vnuthythngbo+OKDovecotreadylc
#telnetlocalhostpop3
Trying127.0.0.1...Connectedtolocalhost.localdomain.Escapecharacteris"^]".+OKDovecotready.
Gquitthot.
Bc13.Toaliasvkimtrashotngcapostfix
Mfilealiasesvthmmtdnggnbdanhchorootnhsau
#vi/etc/aliases
thmdng:
root:mail_admin
Sauchylialiasvkhinglipostfix
#newaliases
-
17/6/2015 Xydngmailserverpostfixvqunlemailbngphpmysql
http://thuonghieuweb.com/content/xaydungmailserverpostfixvaquanlyemailbangphpmysql.html 5/6
#servicepostfixrestart
Kimtradchvpostfixbnglnhsau
#telnetlocalhost25
Saukimtratheohnhsau,nuthygingnhhnhnylok
Bc14:Btutoccdomainvemailaccount
Sauccbctrncthcoinhphnohavktnipostfixvidatabasexongchngtacthtoccdomainvemailgnvidomaincri.Bctoemailaccountnycthdngphpmyadminhocvitmtscriptphpto,qunlemailchonchuynnghip.y,vimcchtestchngtasdngdnglnhtomtdomaintnlmailtest.comvmtemailtnlhai@mailtest.com.
Trctin,chngtakhaibotnminnyvofilehostsgilpmtbnghiDNS
#vi/etc/hosts
Thmdngsau
127.0.0.1mailtest.com
Saubtukhaibodomainnyviusertesttrongcsdliu
#mysqlurootpmysql>USEmailmysql>INSERTINTOdomains(domain)VALUES("mailtest.com")mysql>INSERTINTOusers(email,password)VALUES("[email protected]",ENCRYPT("123456"))mysql>quit
accountmailnycthtruycpImaphayPop3thtaphigi1mail(welcomemessage)chouserbngmttinchgimailsnccalinux,hyglnhnhsau
#mails"xinchao"[email protected]
Gnidungemailngaysaulnhtrn,saubmCtrlD2ln(lnthnhtnhiccthmachcc,lnth2ktthcvgimail)
Sauvothmc/home/vmailkimtra,numithOKbnsnhnthythmcmailtest.comvtrongmailtest.comlicthmchaichaccemailcahai@mailtest.com.Tmlinubnvocngdnny/home/vmail/mailtest.com/hai/Maildir/newvthymtfilethdchnhlemailvacgibngtinchnitrnvnhvypostfixhotngtt.
Bc15:Checkmailthcsvioutlook
cthcheckmailtmtmytnhbtkdngoutlook,bncnphicmtdomainvcquyntrbnghichodomainny.Gisbncdomainlthuonghieuweb.com,hytrccbnghicnthitchoemailtimyachcamychnitrn(bnghiAvbnghiMX)victrbnghikhngcpntrongny.Bnhylmsaosaukhitrbnghibnsphipingthnhcngnachmail.thuonghieuweb.comvthylnctrnipcamychny.
Saubnlplibc14(nhngbquaonsafilehostsvtrtnmintDNSserverri)[email protected].
Moutlooktrnmycabnvkhaibomtaccountminhhnhsau:
-
17/6/2015 Xydngmailserverpostfixvqunlemailbngphpmysql
http://thuonghieuweb.com/content/xaydungmailserverpostfixvaquanlyemailbangphpmysql.html 6/6
Xemthm...
Cclnhlinuxthngdng(phn2)HngdnciApache,PHP,MySQLtrnCentOSKhcphclikhnggimailthngbochousercaDirectAdminNngcpPHP5.1.xlnPHP5.3.28MtslnhqunlMySQLbnnnbitBomtwebsitebngcuhnhapacheMtsththutivilinuxCclnhLinuxthngdngToccnhtuyntnhtrongCentosHngdncuhnhdchvftpchoCentosXllieximdeadbutsubsyslockedvqunlmailqueueeximNgnchnspamtcchostingtrongDirectAdminHngdncitmailservertrnlinuxMtslnhthngdngqunlmailserverpostfixLmthnoghostubuntuHngdncuhnhcardmngchoubuntuHngdncuhnhcardmngchoCentosHngdnxllimysqlvphpmyadminCutrcthmcchuncalinuxHngdnxlliconnectiontostorageserverfailedkhidngmailcadirectadmin8bctoemailgnvitnmincngtyminphtrnlive.comBomtcchostingsdngapachevphpHngdncitsquirrelmailtrnmailserverpostfixChngDDOSviiptables
Saukhikhaiboccthamsnhhnhtrn,bmvotestaccountsettingnuc2bcgi,nhnmailuxanhlOK.cnnukhnghyxemthngbolilgcthkimtrali.
Outlooklmvicrtttvihthngmailpostfixohanytuynhintrongmtstrnghp,chnghnicngtcxa,chngtacncheckmailbngwebmailthcncitthmmtdchvna.HngdncitwebmailctrongbivitHngdncitdchvsquirrelmailgnvipostfix,ccbncthtiptctmhiuthm.
Chcccbnthnhcng
0
BnquynthucvVnphng:Tng4,Tonh65l5,nLII,HongVnTh,HongMai,HNiinthoi(04)39909643Hotline:0989848886Email:[email protected]:www.thuongthieuweb.com
cbovbnquynbi
+1usongoogleplus
1Chias Gi