2009
04.25

There are often times when system administrator or developers want to quickly send out a test email from a Linux server or a requirement to generate email alerts from the scripts performing some housekeeping and monitoring. For example my friend had to generate a daily report on the disk usage level and send out to his clients via email. The command line syntax to send out the email came in handy for his rescue to avoid the daily login, check disk and send the results.

To send an email from a command line all you need is the following steps

First thing make sure make sure the “sendmail” application is installed, running and working correctly.
Execute the following command on the shell command prompt, replacing “yourname@yourdomain.com” with your e-mail address where you want to send the email to.

# mail -s “Hello Test Email” yourname@yourdomain.com

Kick the return key and you will get to a new line. Enter some text which you want to send as the email, for example “This is a simple test from my command line email”. You can enter as many lines by hitting enter after each line.

Finally to end the email message press the key combination of Control+D to continue.

Now the command prompt will ask you if you want to mark a copy of the mail to any other address, hit Control+D again.

Check your mailbox. This command will send out a mail to the email id mentioned with the subject, “Hello Test Email”.

No Comment.

Add Your Comment