Para diagnosticar porque o mail
falha, tente o seguinte:
- abra
~/.mailrc
no seu editor - verifique se ele contém a linha
set verbose
- salve e saia
- tente
echo "hello world" | mail -s "a subject" [email protected]
Você deve ver uma saída detalhada: a minha é assim:
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
procure erros - no meu caso, há duas linhas:
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
para que o e-mail seja rejeitado porque meu host não tem um nome de host totalmente qualificado.
edit: você também pode verificar /var/log/mail.log/
e /var/mail/<yourusername>
se houver alguma informação útil sobre erros.