您的位置:首页 > 大数据 > 人工智能

How to use sendmail to configure SMTP server

2006-04-06 15:29 441 查看

HowtousesendmailtoconfigureSMTPserver

[Environment]
OS:RedhatFedora2
sendmail:8.12.11

[Configuresendmail]
sendmailserverwillberunaccordingtosendmail.cfthatisasealedbook

,sowehadbetternoteditit.sendmail.mcusem4tooltogeneratesendmail.cf,thebestwayistoopenthisfileandmodifyit.Sendmail.mchasverygoodcommentarytoexplaineachentryfunction.Withthehelpofit,ifyoucannotunderstanditcorrectly,pleasevisithttp://www.sendmail.org/whichwillprovideFAQsandtutorials.ThisarticlefocusesonhowtomodifyittobuildSMTPservice,sohere,IwillnotexplainthemindetailJ.
Sendmail.mcislocatedat/etc/maildirectoryinmylinuxserver.Thefollowingstepswilltrymybesttomakeitclearforreaders.
1)Opensendmail.mc
#cd/etc/mail
#vimsendmail.mc
2)Addtwoportstodetectconnectingrequest.Thefollowingcausessendmailtoadditionallylistentoport587formailfromMUAsthatauthenticate.Roaminguserswhocan'treachtheirpreferredsendmaildaemonduetoport25beingblockedorredirectedfindthisuseful.Ifrelativeportshavebeencommented,pleaseremovecommentary.
DAEMON_OPTIONS(`Port=25,Name=MTA')dnl
DAEMON_OPTIONS(`Port=587,Name=MSA,M=Ea')dnl
3)Commenttwoentries.ThefirstentrywillonlylistenontheIPv4loopbackaddress127.0.0.1andnotonanyothernetworkdevices.Removetheloopbackaddressrestrictiontoacceptemailfromtheinternetorintranet.Thesecondentrypermitunresolvabledomainstosendspam(garbargeemails).Wehadbetterdisablethetwofunctions,right?!
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA’)dnl
FEATURE(`accept_unresolvable_domains’)dnl
4)Addoruncommentfourentriesforauthenticatation.Thefisrtandsecondentriesprovideauthenticatingmethod,andPLAINisthepreferredplaintextauthenticationmethod.Thethirddenoteswheretheuserinformationdatabaseforauthentication.Thelastoneisusedtosentemailsoutthroughanexternalmailserver.
TRUST_AUTH_MECH(`EXTERNALDIGEST-MD5CRAM-MD5LOGINPLAIN')dnl
define(`confAUTH_MECHANISMS',`EXTERNALGSSAPIDIGEST-MD5CRAM-MD5LOGINPLAIN')dnl
FEATURE(`authinfo',`hash-o/etc/mail/client-info.db')dnl
define(`SMART_HOST',`smtp.sina.com')
5)Clearallolddababases,andrebuildthemagain.Makefileshouldinvokem4tooltoconvertsendmail.mctosendmail.cf

.
#cd/etc/mail
#makeclean
#make
6)Restartsendmailserver.Ifotheremailserversarerunning,pleasestopthemfirstly.
#servicesendmailrestart

[TIPS]
Howtogetcurrentversionofsendmail?
Therearetwowaystogetcurrentversionofsendmail.Pleasefollowfollowingcommands,theyareexecutedinmylinuxserver.
1)Usetelnettogetversion.Pleaseuse‘ctrl+]’and‘quit’commandtoquittelnetcommand.‘bugzilla’isthedomainnameoflinuxserver.
#telnetbugzilla25
Trying127.0.0.1...
ConnectedtoBugzillaTestServer(127.0.0.1).
Escapecharacteris'^]'.
220bugzilla.utl.comESMTPSendmail8.12.11/8.12.11;Thu,6Apr200613:49:13+0800
^]
telnet>quit
Connectionclosed.
2)Usesendmail’sdebuggingoptionstoshowcurrentversion.
#sendmail-d0.1
Version8.12.11
Compiledwith:DNSMAPHESIODHES_GETMAILHOSTLDAPMAPLOGMAP_REGEX
MATCHGECOSMILTERMIME7TO8MIME8TO7NAMED_BINDNETINETNETINET6
NETUNIXNEWDBNISPIPELININGSASLv2SCANFSTARTTLSTCPWRAPPERS
USERDBUSE_LDAP_INIT
============SYSTEMIDENTITY(afterreadcf)============
(shortdomainname)$w=bugzilla
(canonicaldomainname)$j=bugzilla.utl.com
(subdomainname)$m=utl.com
(nodename)$k=BugzillaTestServer
========================================================
Recipientnamesmustbespecified

Howtobuildclient-infodatabase?
1)Createclient-infofileatthe/etc/mail,andinputcontents:
AuthInfo:your.isp.net"U:root""I:user""P:password".
Forexample,
AuthInfo:stmp.sina.com“U:root”“I:hello_wyq”“P:no_ways”.
Aftereditingit,pleasesaveandcloseit.Ofcourse,
youcancreatethisfileinanydirectory,and
use‘ln–syour_directory/client-info/etc/mail/client-info’tolinkit.
Pleaserememberthattheaccessrightmustberootforsafety!

2)Generateclient-info.dbfile.Therearetwowaystocreateit.

I)Use‘makemap’commanddirectly

#cd/etc/mail

#chmod600client-info

#makemaphashclient-info<client-info

#chmod600client-info.*

#m4sendmail.mc>sendmail.cf

II)UseMakefile,andaddclient-info.dbinthe‘all:’tag.
Makefilewillautomaticallygeneratesendmail.cfinthe
lightofsendmail.mc.

#cd/etc/mail

#chmod600client-info

#makeclean

#make


HowtoconfirmwhetherSASLhasbeeninitialized?
#sendmail-d0.1-bvroot|grepSASL
NETUNIXNEWDBNISPIPELININGSASLv2SCANFSTARTTLSCPWRAPPERS
Iftherearesomewordslikeabove,itmeansthatSASLhasbeeninitialized.SASLisessentialelementforauthentication.

HowtocheckwhetherPLAINhasbeeninitialized?
[root@BugzillaTestServermail]#telnetbugzilla25
Trying127.0.0.1...
Connectedtobugzilla.utl.com(127.0.0.1).
Escapecharacteris'^]'.
220bugzilla.utl.comESMTPSendmail8.12.11/8.12.11;Thu,6Apr200615:15:42+0800
EHLObugzilla
250-bugzilla.utl.comHelloBugzillaTestServer[127.0.0.1],pleasedtomeetyou
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTHGSSAPIDIGEST-MD5CRAM-MD5LOGINPLAIN
250-DELIVERBY
250HELP
^]
telnet>quit
Connectionclosed.
IfPLAINisshown,itmeansthattheconfigurationisOK.

HowtotestwhetherwecansendemailsbySMTPserver?
#echo'Testbodyofemailandnotitile'|sendmail-vhello_wyq@sina.com
hello_wyq@sina.com...Connectingto[127.0.0.1]viarelay...
220bugzilla.utl.comESMTPSendmail8.12.11/8.12.11;Thu,6Apr200615:20:52+0800
>>>EHLObugzilla.utl.com
250-bugzilla.utl.comHelloBugzillaTestServer[127.0.0.1],pleasedtomeetyou
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTHGSSAPIDIGEST-MD5CRAM-MD5LOGINPLAIN
250-DELIVERBY
250HELP
>>>MAILFrom:<root@bugzilla.utl.com>SIZE=33AUTH=root@bugzilla.utl.com
2502.1.0<root@bugzilla.utl.com>...Senderok
>>>RCPTTo:<hello_wyq@sina.com>
>>>DATA
2502.1.5<hello_wyq@sina.com>...Recipientok
354Entermail,endwith"."onalinebyitself
>>>.
2502.0.0k367Kq5j006558Messageacceptedfordelivery
hello_wyq@sina.com...Sent(k367Kq5j006558Messageacceptedfordelivery)
Closingconnectionto[127.0.0.1]
>>>QUIT
2212.0.0bugzilla.utl.comclosingconnection
Pleasecheckyouremailinboxwhethernosubject’semailhasbeenreceived

,goodLuck!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: