Sending mail from terminal in Linux using SMTP server

posted in: Linux | 0

The best way I found was using a package called mailx. In ubuntu simply do the following:

 sudo apt-get install heirloom-mailx 

Next we need to make sure that the user that wants to send the mail has the correct configuration. So in the the user’s home directory, create a file called ~/.mailrc

The contents of the file should look something like the following:

set smtp=smtp://
set from=" (Sender Name)"
set smtp-auth=login set
set smtp-auth-password=yourpassword 

There you have it. To send a mail, use the following:

 mailx -s 'Hello World' < msg 

For more information there’s always the man pages.

Leave a Reply