使用邮件发送邮件挂起 - Ubuntu 14.04

使用邮件发送邮件挂起 - Ubuntu 14.04

我尝试使用 ubuntu shell 发送电子邮件,当我执行以下命令时,会话被挂起。请帮助我。

echo“你好,世界”|邮件-s“主题”[电子邮件保护]

一段时间后,终端会抛出以下消息。

邮件:无法发送消息:进程以非零状态退出

答案1

要诊断mail失败原因,请尝试以下操作:

  • ~/.mailrc在编辑器中打开
  • 确保它包含行set verbose
  • 保存并退出
  • 尝试echo "hello world" | mail -s "a subject" [email protected]

您应该看到详细的输出——我的看起来像这样:

root@vagrant-ubuntu-trusty-64:~# echo "test" | mail -s "test" rafal@(...)
WARNING: local host name (vagrant-ubuntu-trusty-64) is not qualified; see cf/README: WHO AM I?
rafal@(...)... Connecting to [127.0.0.1] via relay...
220 vagrant-ubuntu-trusty-64 ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Thu, 28 Jul 2016 10:43:54 GMT; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO vagrant-ubuntu-trusty-64
250-vagrant-ubuntu-trusty-64 Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<vagrant@vagrant-ubuntu-trusty-64> SIZE=209  AUTH=vagrant@vagrant-ubuntu-trusty-64
250 2.1.0 <vagrant@vagrant-ubuntu-trusty-64>... Sender ok
>>> RCPT To:<rafal@(...)>
>>> DATA
250 2.1.5 <rafal@(...)>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <rafal@(...)>... Connecting to (...). via esmtp...
050 220 (...) ESMTP Postfix (Debian/GNU)
050 >>> EHLO vagrant-ubuntu-trusty-64
050 250-(...)
050 250-PIPELINING
050 250-SIZE 10240000
050 250-VRFY
050 250-ETRN
050 250-STARTTLS
050 250-AUTH PLAIN LOGIN
050 250-ENHANCEDSTATUSCODES
050 250-8BITMIME
050 250 DSN
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO vagrant-ubuntu-trusty-64
050 250-(...)
050 250-PIPELINING
050 250-SIZE 10240000
050 250-VRFY
050 250-ETRN
050 250-AUTH PLAIN LOGIN
050 250-ENHANCEDSTATUSCODES
050 250-8BITMIME
050 250 DSN
050 >>> MAIL From:<vagrant@vagrant-ubuntu-trusty-64> SIZE=467 AUTH=<>
050 250 2.1.0 Ok
050 >>> RCPT To:<rafal@(...)>
050 >>> DATA
050 504 5.5.2 <vagrant-ubuntu-trusty-64>: Helo command rejected: need fully-qualified hostname
050 554 5.5.1 Error: no valid recipients
050 >>> RSET
050 250 2.0.0 Ok
050 <vagrant@vagrant-ubuntu-trusty-64>... Connecting to local...
050 <vagrant@vagrant-ubuntu-trusty-64>... Sent
250 2.0.0 u6SAhslg010491 Message accepted for delivery
rafal@(...)... Sent (u6SAhslg010491 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 vagrant-ubuntu-trusty-64 closing connection

查找任何错误 - 在我的例子中,有以下两行:

050 504 5.5.2 <vagrant-ubuntu-trusty-64>: Helo command rejected: need fully-qualified hostname
050 554 5.5.1 Error: no valid recipients

因此邮件被拒绝,因为我的主机没有完全合格的主机名。

编辑:您还可以检查/var/log/mail.log/是否/var/mail/<yourusername>有有关错误的有用信息。

相关内容