Sending an email from console is an easy procedure that comes in handy. I use it a lot, mainly when I setup a new mail server to send test email or when I want to send the contents of a big configuration file.
To install the mail command in red-hat based distributions, issue
yum install mailx
To install the mail command in debian based distributions, issue
apt-get install bsd-mailx
To send an email from console
- Issue the mail command followed by the recipient email address press enter
- Enter the desired subject press enter
- Enter the desired main body of the email press enter
- type “.” a dot press enter
- If you want to cc it to somebody else enter the email address, else leave it blankĀ press enter
[root@host ~]# mail user@domain.com
Subject: this is the subject of the email
THIS IS THE MAIN TEXT OF THE EMAIL
text text text
blah blah blah
text text
.
Cc: user2@domain.com
[root@host ~]#
If you want to send the contents of a file, issue the mail command again in the following form
[root@host ~]# mail -s ‘subject’ user@domain.com < /path/to/file/filename
I have installed bsd-mailx, and still can’t sending email to my Gmail account.
Please let me know step by step installing bsd-mailx + configuration on ubuntu.
Thanks