4

There appear to be a number of answers to this question, but none of them seem to work: I would like to send email from my localhost to a gmail account. The following command does nothing as far as I can tell:

mail -s "Hello!" address@gmail.com

After Ctrl-Ding to finish editing, there is no failure notification or anything, and the message never appears in that gmail account's inbox (or spam folder). I've tried various different ways of using that command from around the internet, but it appears that it just silently fails to send to nonlocal addresses. Any ideas? I am using Debian Wheezy

EDIT: To be clear, the issue is not that I get command line prompts, which I know I can avoid with pipes etc. The issue is that mail is simply never sent. The command returns after a while, and it just silently fails.

Thanks!

Carson McNeil
  • 790
  • 9
  • 22
  • use *mailx* which works for me – totti Mar 15 '15 at 06:05
  • Edit your original question and include the log messages that show what your server says happened when it sent it to gmail. If you have a Debian system, it will be in /var/log/mail.log. – Todd Lyons Mar 16 '15 at 04:27
  • [`mail`](https://unix.stackexchange.com/a/299509/209677) just composes, doesn't know anything about SMTP protocol. Check [this answer using `s-nail`](https://askubuntu.com/a/1295167/349837). In any case you'll need to have an account on a mail server – Pablo Bianchi Jul 30 '22 at 06:22

2 Answers2

0

You can use an echo with a pipe to avoid prompts or confirmation.

echo "This is the body" | mail -s "This is the subject" address@gmail.com

Bob Stevens
  • 114
  • 6
  • So, avoiding prompts or confirmation is not the issue. The issue is that the mail never gets sent. The above line hangs for a while, and returns, while never sending a message to the specified address, or printing any sort of error. – Carson McNeil Mar 14 '15 at 18:18
0

Make sure postfix or the MTA of your choice is installed and running.

sudo /etc/init.d/postfix status
usr242
  • 36
  • 2