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,pleasevisit
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!
相关文章推荐
- how-to-configure-and-use-spark-history-server
- How to configure postfix to user other SMTP server
- How to configure Gmail as the SMTP server
- How to configure a SMTP server in Red Hat Enterprise Linux
- How to use ASMCA in silent mode to configure ASM for a stand-alone server [ID 1068788.1]
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How To Install / Configure VNC Server On CentOS 7.0
- 解决 PHP Interpreter is not configured Please configure PHP Interpreter to use built-in web server
- Linux: How to Configure the DNS Server for 11gR2 SCAN [ID 1107295.1]
- How To Configure Server Side Transparent Application Failover [ID 460982.1]
- how to use danymic sql in SQL Server 2000
- How to configure OpenFiler v2.3 iSCSI Storage for use with VMware ESX.
- How to use ServerCore<2>
- How to use GDI+?simle introduction about configure
- Generating user instances in Sql Server is disabled. Use sp_configure 'user instances enabled' to generate user instances
- Linux: How to Configure the DNS Server for 11gR2 SCAN (Doc ID 1107295.1)
- How to send Email through external SMTP server on Ubuntu 14.04
- How to Install and Configure Bind 9 (DNS Server) on Ubuntu / Debian System
- How To Configure Server Side Transparent Application Failover [ID 460982.1]
- How To Configure Server Side Transparent Application Failover [ID 460982.1]