To diagnose why mail
fails, try the following:
- open
~/.mailrc
in your editor
- make sure it contains line
set verbose
- save and exit
- try
echo "hello world" | mail -s "a subject" your@addres.com
You should see detailed output - mine looks like this:
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
look for any errors - in my case there were these two lines:
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
so the mail was rejected because my host does not have a fully-qualified hostname.
edit: you can also check /var/log/mail.log/
and /var/mail/<yourusername>
if there is any useful information about errors.
post the output of
echo "hello world" | mail -v -s "a subject" abc@gmail.com
(notice the-v
aftermail
). – rafalmp – 2016-07-26T17:58:15.850echo "hello world" | mail -V -s "a subject" dasith9@gmail.com mail (GNU Mailutils) 2.99.98 Copyright (C) 2010 Free Software Foundation, inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
– Daz – 2016-07-27T09:59:38.600No, it has to be
-v
not-V
, small letter 'v' not capital one: – rafalmp – 2016-07-27T11:15:24.053thanks for the support. This is what I am getting
mail: invalid option -- 'v' Try 'mail --help' or 'mail --usage' for more information.
– Daz – 2016-07-28T04:29:43.553ok one more time - the whole command as it should be entered in terminal:
echo "hello world" | mail -v -s "a subject" dasith9@gmail.com mail
– rafalmp – 2016-07-28T09:24:13.207Still Same :(
mail: invalid option -- 'v' Try 'mail --help' or 'mail --usage' for more information.
– Daz – 2016-07-28T09:27:45.377Ah sorry my bad, gnu mail has no 'verbose' option... You can insert the line
set verbose
in your~/.mailrc
(create it if does not exist) then delivery details will be printed on screen - there should be some helpful information. – rafalmp – 2016-07-28T09:47:32.173I have just add
set verbose
using vi. Still same. Can you guide me on this :( – Daz – 2016-07-28T09:51:41.013