3

How I can send a simple mail from Ubuntu command line without giving the password for the email account which I'm sending to?

4
  • If the question below worked, be sure to accept it by toggling the grey tick just beneath the answer's downvote button
    – TellMeWhy
    Nov 26, 2015 at 10:23
  • "The password for the account you're sending to"? No mail service asks the target account's password. O.o
    – muru
    Nov 26, 2015 at 10:27
  • @muru I think OP meant "without password for the email account I'm using"?
    – TellMeWhy
    Nov 26, 2015 at 10:29
  • 1
    @DevRobot That's what I think too. But I wonder if they used some command which asked for some password which they mistook for the target account's pw.
    – muru
    Nov 26, 2015 at 10:31

2 Answers 2

4
sudo apt-get install mailutils
mail -s "Subject" [email protected]

Press enter and write the subject of your email. Use Ctrl+D to continue.

You will be asked if you want to mark a copy of the mail to any other address - you can skip that with Ctrl+D.

The email will now be sent to your chosen address.

1
  • On 14.04, at least you must install the package mailutils first: The program 'mail' is currently not installed. You can install it by typing: sudo apt-get install mailutils
    – Mark Kirby
    Nov 26, 2015 at 9:34
4
echo "Mail text" | mail -s "Subject" [email protected]
2
  • How is this any better than DevRobot's answer?
    – muru
    Nov 26, 2015 at 10:59
  • 3
    sending mail whithout text typing, can do some nice things like df -h | mail -s "Disk Info" [email protected], redirect logs to your email sudo cat /var/log/syslog | mail -s "logs" [email protected]. Just a suggestion...
    – shamsky
    Nov 26, 2015 at 11:13

Not the answer you're looking for? Browse other questions tagged .