Why am I not able to send an email from command line

15,359

Solution 1

You need to install several packages namely as follows

 postfix mailutils libsasl2-2 ca-certificates libsasl2-modules

these packages are required for the proper setup of mail sending. Here is a proper way of setting this up and testing out by sending mail and the possible troubleshooting. Hope this helps :)

Solution 2

You will need to install a mail transfer agent. I would suggest Postfix, since it is widely used and has a good security record:

sudo apt-get install postfix

You should be asked a few questions about how you want to configure Postfix. If your ISP requires you to send email via their SMTP server, choose the "Satelite system" option and enter their SMTP server as the relay host. Otherwise, the "Internet site" option is probably best.

With that set up, the mail command line tool should be able to deliver email (along with anything else that relies on the /usr/lib/sendmail API).

Share:
15,359

Related videos on Youtube

dearN
Author by

dearN

Updated on September 18, 2022

Comments

  • dearN
    dearN over 1 year

    This is what I did (as per a few discussions on this website)

    mail -s "hi" [email protected] < test.txt

    Where text.txt has the message.

    I checked to see if mail did exist and it does at /usr/bin/mail

    What am I missing? Is there a daemon that must be running? Is there more to this?

    I am running Ubuntu 11.10

    • Admin
      Admin over 12 years
      Might be that you must be in mail group to do that: sudo adduser your-user-here mail
    • Admin
      Admin over 12 years
      @Reinis Thanks for your comment. Who exactly is your-user-here? The recipient, I am guessing? I'll try it out anyway.
    • Admin
      Admin over 12 years
      your-user-here is your username you have in your shell! You can see the username you use with before the @ sign in the shell, mine : marc-andre@T1500:$
    • Admin
      Admin over 12 years
      If you type id at the command line it will show you what groups you are in. Please add that to your question. Also what MTA are you using - postfix is the default one on ubuntu. If you do ps -ef | grep postfix what is the output?
    • Admin
      Admin over 12 years
      @HamishDowner Postfix isn't running. So I guess as per the comment below, I should first sudo apt-get install postfix