I am working in the computer at home I want to send me an email and I tried:

uuencode all.sh all.sh | mail mymail@gmail.com 

But the problem is that nothing arrive to my email, I just get the following error:

mail: cannot send message: Process exited with a non-zero status

The fact is that I use the same command in the work and it works well I would like to appreciate any suggestion to fix this problem. I am not sure If a have to set up any file before to use that command line in my personal computer. I tried also with installing mutt:

mutt myemail@gmail.com < all.sh 

but I got the following error:

sendmail: Cannot open mail:25
Error sending message, child exited 1 ().
Could not send the message.
  • What is your mail server on the machine? (postfix used on most distros today, or maybe dovecot, I believe it is used by ubuntu). – grochmal Jul 31 '16 at 23:49
  • Yes in fact I am using ubuntu 14.04 LTS, – neo33 Jul 31 '16 at 23:50
  • I have a question, Do you mean that I need to use mutt instead mail? – neo33 Aug 1 '16 at 0:10
  • I tried that but I got an error i added it to the description of the problem to be more clear. – neo33 Aug 1 '16 at 0:12
  • The main idea that I would like to achieve is to send and email to my account from my terminal. – neo33 Aug 1 '16 at 0:18

The basic mail command is only a mail reader and composer, it doesn't know how to talk to a server over the network (with the SMTP protocol). Talking SMTP is the job of a MTA (message transfer agent). The default MTA on Ubuntu is Postfix. To configure Postfix, run

sudo dpkg-reconfigure postfix

If you only want to send mail and not receive any, choose “Satellite system”.

Note that unless you have a permanently-connected machine, with suitable DNS entries, and preferably with a static IP address, you can't directly receive mail: you have to use an external server, and then fetch the mail using a protocol such as IMAP.

Ubuntu includes several versions of the mail command. The heirloom-mailx version does know how to talk SMTP. You configure it in ~/.mailrc. The configuration might look something like this:

set smtp=smtp.example.com
set smtp-use-starttls
set smtp-auth-user=neo33
set smtp-auth-password=swordfish
  • Just one question where can I find this file ~/.mailrc I mean in what directory? and shoud I put my email in the line called: set smtp=smtp.example.com ? – neo33 Aug 1 '16 at 0:40
  • 1
    @neo33 ~ means your home directory. The settings in the file are not your email address (you put that in the From header), they're the SMTP settings for your mail provider. – Gilles 'SO- stop being evil' Aug 1 '16 at 0:49
  • Yes I see, to configure that do I have to create that file at the home level? – neo33 Aug 1 '16 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.