Why am I not able to send an email from command line
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).
Related videos on Youtube
dearN
Updated on September 18, 2022Comments
-
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 over 12 yearsMight be that you must be in mail group to do that:
sudo adduser your-user-here mail
-
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 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 over 12 yearsIf 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 dops -ef | grep postfix
what is the output? -
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
-