sendmail 发送邮件前需要配置吗?

sendmail 发送邮件前需要配置吗?

“sendmail” 是预先安装的,我认为不需要配置。

我是对的还是错的?

但事实上我没能发出邮件!

[root@jiaoyou ~]# cat mail2.txt
From: [email protected]
To: [email protected]
MIME-Version: 1.0
Content-Type: multipart/alternative;
Subject: Test HTML e-mail.

This is a MIME-encapsulated message

[root@jiaoyou ~]# sendmail -t -d <mail2.txt 
Version 8.14.3
 Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
                MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
                NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
                TCPWRAPPERS USERDB USE_LDAP_INIT
getla(): 0.00
setoption SevenBitInput (7)=False
setoption AliasWait (a)=10
setoption MinFreeBlocks (b)=100
setoption BlankSub (B)=.
setoption HoldExpensive (c)=False
setoption DeliveryMode (d)=i
setoption QueueFileMode (0xbe)=0660
setoption TempFileMode (F)=0600
setoption HelpFile (H)=/etc/mail/helpfile
setoption SendMimeErrors (j)=True
setoption ForwardPath (J)=
setoption ConnectionCacheSize (k)=2
setoption ConnectionCacheTimeout (K)=5m
setoption UseErrorsTo (l)=False
setoption LogLevel (L)=9
setoption CheckAliases (n)=False
setoption OldStyleHeaders (o)=True
setoption DaemonPortOptions (O)=Name=NoMTA, Addr=127.0.0.1, M=E
Daemon NoMTA flags: <NOETRN>
setoption UseMSP (0xcc)=True
setoption PrivacyOptions (p)=goaway,noetrn,restrictqrun
setoption QueueDirectory (Q)=/var/spool/clientmqueue
setoption Timeout (r).queuereturn=5d
setoption Timeout (r).queuewarn=4h
setoption SuperSafe (s)=True
setoption StatusFile (S)=/var/spool/clientmqueue/sm-client.st
setoption TimeZoneSpec (t)=
setoption SmtpGreetingMessage (0x90)= 0x81 j Sendmail  0x81 v/ 0x81 Z;  0x81 b
setoption UnixFromLine (0x91)=From  0x81 g  0x81 d
setoption OperatorChars (0x92)=.:%@!^/[]+
setoption DontInitGroups (0x93)=True
setoption RunAsUser (0x9d)=smmsp
setoption DontProbeInterfaces (0xa1)=True
setoption TrustedUser (0xa7)=smmsp
setoption PidFile (0x9f)=/var/run/sm-client.pid
drop_privileges(0): Real[UG]id=0:0, get[ug]id=0:0, gete[ug]id=0:51, RunAs[UG]id=51:51
getauthinfo: root@localhost

============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = jiaoyou
  (canonical domain name) $j = jiaoyou
         (subdomain name) $m = <null>
              (node name) $k = jiaoyou
========================================================

assign_queueid: assigned id n7QFdKGA008587, e=0x7f32a15d1fa0
assign_queueid: assigned id n7QFdKGB008587, e=0x7f32a15d1fa0
getla(): 0.00
setsender()

--parseaddr(root)
rewrite: ruleset canonify           input: root
rewrite: ruleset Canonify2          input: root
rewrite: ruleset Canonify2        returns: root
rewrite: ruleset canonify         returns: root
rewrite: ruleset parse              input: root
rewrite: ruleset Parse0             input: root
map_lookup(dequote, root) => NOT FOUND (0)
rewrite: ruleset Parse0           returns: root
rewrite: ruleset Parse1             input: root
rewrite: ruleset Parse1           returns:  0x96  local  0x98  root
rewrite: ruleset parse            returns:  0x96  local  0x98  root
rewrite: ruleset 2                  input: root
rewrite: ruleset 2                returns: root
rewrite: ruleset EnvToL             input: root
rewrite: ruleset EnvToL           returns: root
rewrite: ruleset final              input: root
rewrite: ruleset final            returns: root
parseaddr-->0x7f32a15d1fc0=root:
        mailer 3 (local), host `'
        user `root', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=180<QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)
rewrite: ruleset canonify           input: root
rewrite: ruleset Canonify2          input: root
rewrite: ruleset Canonify2        returns: root
rewrite: ruleset canonify         returns: root
rewrite: ruleset 1                  input: root
rewrite: ruleset 1                returns: root
rewrite: ruleset final              input: root
rewrite: ruleset final            returns: root
EOH
----- collected header -----
Return-Path: < 0x81 g>
Received:(  0x81 ?sfrom  0x81 s  0x81 . 0x81 ?_( 0x81 ?s 0x81 |from  0x81 . 0x81 _)\n\t 0x81 . 0x81 ? 0xa5 (authenticated 0x81 ? 0xa6  bits= 0x81  0xa6  0x81 .)\n\t 0x81 .by  0x81 j ( 0x81 v/ 0x81 Z) 0x81 ?r with  0x81 r 0x81 . id  0x81 i 0x81 ? 0xa7 \n\t(version= 0x81  0xa7  cipher= 0x81  0xa8  bits= 0x81  0xa9  verify= 0x81  0xaa ) 0x81 . 0x81 ?u\n\tfor  0x81 u;  0x81 |;\n\t 0x81 . 0x81 b)  (from root@localhost)\n\tby jiaoyou (8.14.3/8.14.3/Submit) id n7QFdKGB008587;\n\tWed, 26 Aug 2009 11:39:20 -0400
Resent-Date:(  0x81 a)  Wed, 26 Aug 2009 11:39:20 -0400
Date:(  0x81 a)  Wed, 26 Aug 2009 11:39:20 -0400
Resent-From:(  0x81 ?x 0x81 x < 0x81 g> 0x81 | 0x81 g 0x81 .) crackaddr( root <root>)
crackaddr=>` root < 0x81 g>'
 root <root>
From:<NULL>
Full-Name:(  0x81 x)  root
Resent-Message-Id:( < 0x81 t. 0x81 i@ 0x81 j>)  <200908261539.n7QFdKGB008587@jiaoyou>
Message-Id:( < 0x81 t. 0x81 i@ 0x81 j>)  <200908261539.n7QFdKGB008587@jiaoyou>
From: [email protected]
To: [email protected]
sendto:  [email protected]
   ctladdr=[NULL]

--parseaddr([email protected])
rewrite: ruleset canonify           input: shore . cloud @ gmail . com
rewrite: ruleset Canonify2          input: shore . cloud < @ gmail . com >
map_lookup(host, gmail.com) => host_map_lookup(gmail.com) => map_rewrite(gmail.com), av =
        gmail.com
map_rewrite => gmail.com.
FOUND gmail.com
gmail.com. (0)
rewrite: ruleset Canonify2        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset canonify         returns: shore . cloud < @ gmail . com . >
rewrite: ruleset parse              input: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0             input: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0           returns: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse1             input: shore . cloud < @ gmail . com . >
rewrite: ruleset MailerToTriple     input: < > shore . cloud < @ gmail . com . >
rewrite: ruleset MailerToTriple   returns: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse1           returns:  0x96  esmtp  0x97  gmail . com .  0x98  shore . cloud < @ gmail . com . >
rewrite: ruleset parse            returns:  0x96  esmtp  0x97  gmail . com .  0x98  shore . cloud < @ gmail . com . >
rewrite: ruleset 2                  input: shore . cloud < @ gmail . com . >
rewrite: ruleset 2                returns: shore . cloud < @ gmail . com . >
rewrite: ruleset EnvToSMTP          input: shore . cloud < @ gmail . com . >
rewrite: ruleset PseudoToReal       input: shore . cloud < @ gmail . com . >
rewrite: ruleset PseudoToReal     returns: shore . cloud < @ gmail . com . >
rewrite: ruleset MasqSMTP           input: shore . cloud < @ gmail . com . >
rewrite: ruleset MasqSMTP         returns: shore . cloud < @ gmail . com . >
rewrite: ruleset EnvToSMTP        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset final              input: shore . cloud < @ gmail . com . >
rewrite: ruleset final            returns: shore . cloud @ gmail . com
parseaddr-->[email protected]:
        mailer 5 (esmtp), host `gmail.com.'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=180<QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)

recipient (0): [email protected]:
        mailer 5 (esmtp), host `gmail.com.'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)
maplocaluser: [email protected]:
        mailer 5 (esmtp), host `gmail.com.'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=(none)
rewrite: ruleset localaddr          input: shore . cloud @ gmail . com
rewrite: ruleset Local_localaddr    input: shore . cloud @ gmail . com
rewrite: ruleset ParseRecipient     input: shore . cloud @ gmail . com
rewrite: ruleset CanonAddr          input: shore . cloud @ gmail . com
rewrite: ruleset canonify           input: shore . cloud @ gmail . com
rewrite: ruleset Canonify2          input: shore . cloud < @ gmail . com >
map_lookup(host, gmail.com) => host_map_lookup(gmail.com) => CACHE gmail.com
map_rewrite(gmail.com), av =
        gmail.com
map_rewrite => gmail.com.
gmail.com. (0)
rewrite: ruleset Canonify2        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset canonify         returns: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0             input: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0           returns: shore . cloud < @ gmail . com . >
rewrite: ruleset CanonAddr        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset ParseRecipient   returns: shore . cloud < @ gmail . com >
rewrite: ruleset Local_localaddr  returns:  0x96  relay  0x97  [ 127 . 0 . 0 . 1 ]  0x98  shore . cloud < @ gmail . com >
rewrite: ruleset localaddr        returns:  0x96  relay  0x97  [ 127 . 0 . 0 . 1 ]  0x98  shore . cloud < @ gmail . com >
rewrite: ruleset 2                  input: shore . cloud < @ gmail . com >
rewrite: ruleset 2                returns: shore . cloud < @ gmail . com >
rewrite: ruleset MasqSMTP           input: shore . cloud < @ gmail . com >
rewrite: ruleset MasqSMTP         returns: shore . cloud < @ gmail . com >
rewrite: ruleset final              input: shore . cloud < @ gmail . com >
rewrite: ruleset final            returns: shore . cloud @ gmail . com

recipient (1): [email protected]:
        mailer 8 (relay), host `[127.0.0.1]'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x0, alias 0x7f32a16a4598, uid 0, gid 0
        flags=182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=(none)
MIME-Version: 1.0
Content-Type: multipart/alternative;
Subject: Test HTML e-mail.
----------------------------
From person = "root"
getla(): 0.00

===== SENDALL: mode i, id n7QFdKGB008587, e_from 0x7f32a15d1fc0=root:
        mailer 3 (local), host `'
        user `root', ruser `<null>'
        state=SENDER, next=0x0, alias 0x0, uid 0, gid 0
        flags=181<QGOODUID,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="/root", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)
        e_flags = 4605041<OLDSTYLE,DELETE_BCC,GLOBALERRS,METOO,HAS_DF,IS_MIME,SPLIT>
sendqueue:
[email protected]:
        mailer 8 (relay), host `[127.0.0.1]'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=(none)
[email protected]:
        mailer 5 (esmtp), host `gmail.com.'
        user `[email protected]', ruser `<null>'
        state=REPLACED, next=0x0, alias 0x0, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=(none)

>>>>> queueing /var/spool/clientmqueue/./qfn7QFdKGB008587 (new id) >>>>>
queueing [email protected]:
        mailer 8 (relay), host `[127.0.0.1]'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=(none)
remotename([email protected])
remotename([email protected])
<<<<< done queueing n7QFdKGB008587 <<<<<


--deliver, id=n7QFdKGB008587, mailer=relay, host=`[127.0.0.1]', first user=`[email protected]'
remotename(root)
rewrite: ruleset canonify           input: root
rewrite: ruleset Canonify2          input: root
rewrite: ruleset Canonify2        returns: root
rewrite: ruleset canonify         returns: root
rewrite: ruleset 1                  input: root
rewrite: ruleset 1                returns: root
rewrite: ruleset EnvFromSMTP        input: root
rewrite: ruleset PseudoToReal       input: root
rewrite: ruleset PseudoToReal     returns: root
rewrite: ruleset MasqSMTP           input: root
rewrite: ruleset MasqSMTP         returns: root < @ *LOCAL* >
rewrite: ruleset MasqEnv            input: root < @ *LOCAL* >
rewrite: ruleset MasqEnv          returns: root < @ jiaoyou . >
rewrite: ruleset EnvFromSMTP      returns: root < @ jiaoyou . >
rewrite: ruleset final              input: root < @ jiaoyou . >
rewrite: ruleset final            returns: root @ jiaoyou
remotename => `root@jiaoyou'
hostsignature([127.0.0.1]) = [127.0.0.1]

send to [email protected]:
        mailer 8 (relay), host `[127.0.0.1]'
        user `[email protected]', ruser `<null>'
        state=OK, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=(none)
checkcompat([email protected], from=root)
openmailer: TCP [127.0.0.1]
makeconnection ([127.0.0.1] [127.0.0.1].25 (10))
makeconnection: fd=6
Connecting to [127.0.0.1]...
Connect failed (Connection refused by [127.0.0.1]); retrying with AF_INET....
makeconnection ([127.0.0.1] [127.0.0.1].25 (2))
makeconnection: fd=6
Connecting to [127.0.0.1]...
Connect failed (Connection refused by [127.0.0.1])
openmailer: makeconnection => stat=75, errno=111
openmailer: MCI@0x7f32a16926c8: flags=0,
        errno=111, herrno=0, exitstat=75, state=0, pid=0,
        maxsize=0, phase=initial connection, mailer=relay,
        status=4.4.1, rstatus=(null),
        host=[127.0.0.1], lastuse=Wed Aug 26 11:39:21 2009

dropenvelope 0x7f32a15d1fa0: id=n7QFdKGB008587, flags=4605043<OLDSTYLE,INQUEUE,DELETE_BCC,GLOBALERRS,METOO,HAS_DF,IS_MIME,SPLIT>

>>>>> queueing /var/spool/clientmqueue/./qfn7QFdKGB008587 >>>>>
queueing [email protected]:
        mailer 8 (relay), host `[127.0.0.1]'
        user `[email protected]', ruser `<null>'
        state=QUEUEUP, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=[127.0.0.1], status=4.4.1
        finalrcpt="RFC822; [email protected]"
        rstatus="(none)"
        statdate=Wed Aug 26 11:39:21 2009

remotename([email protected])
remotename([email protected])
<<<<< done queueing n7QFdKGB008587 <<<<<


====finis: stat 75 e_id=NOQUEUE e_flags=4405043<OLDSTYLE,INQUEUE,DELETE_BCC,GLOBALERRS,METOO,IS_MIME,SPLIT>

答案1

简短的回答是“不,不需要配置即可发送电子邮件。”

长答案是,“如果您想发送/接收电子邮件,您可能需要查看并配置它。如果您想拥有一个功能良好的邮件服务器,您还需要查看您的 DNS、SPF 记录、反向 PTR 记录等。”

正确配置邮件服务器实际上需要相当多的工作。

如果您想要做的只是让脚本偶尔发送电子邮件……那么您可能没问题。(除非您的邮件服务器对垃圾邮件很严厉,并且检查邮件以确保发送服务器确实是邮件服务器……但我离题了……)

希望这可以帮助。

答案2

在许多系统上,Sendmail 初始安装后仅会向外发送邮件。如果您希望在系统上接收来自外部服务的电子邮件,则需要重新配置它。

相关内容