I needed to send email from the command line, and as my previous post here. now we are going to use the gnu mailutils package on our ubuntu machine so first off let’s install the mailutils package:
# apt-get install mailutils
(This will add a few extra packages)
To send an email from console you need to use mail command, which is an intelligent mail processing system which has a command syntax reminiscent of ed with lines replaced by messages.
To send an email to [email protected] you need to type following command:
$ mail [email protected]
Kamusta kana? sana ok ka/// :)
. <Type DOT (.) followed by ENTER KEY>
Cc: <Press ENTER KEY>
You need to type . (dot) to send an email.
To send contains of file (such as /var/log/messages) as mail body then use following command:
$ mail -s 'Subject here' [email protected] < /var/log/messages
Please note that above command will NOT route an email if you do not have properly configured MTA/mail server. and check your spam folder for paid services like gmail for the mail might end up there