Howto send email from Ubuntu with Gmail

    The purpose of this document is show you how to send email form Ubuntu with Gmail. There is a package designed just for this mission: ssmtp. So, if you want to send mail from your Ubuntu desktop, It is a good choise. Let`s just install ssmtp.


    NOTE Before you complete the following steps, need to delete Postfix/sendmail packages.

    Install ssmtp

    $sudo apt-get install ssmtp mailutils

    Configuration ssmtp

    Then edit the ssmtp configuration file:

    $sudo vim /etc/ssmtp/ssmtp.conf

    Comment out the “root” , “hostname” and “mailhub” lines. Add the following a the end of this file:
    AuthUser=your_gmail_username #

    Configure SSMTP “/etc/ssmtp/revaliases” file to looks like:

    root:<YOUR EMAIL>

    Then, save the change. Add the “heirloom-mailx” as mail application in command line.

    $sudo apt-get install heirloom-mailx

    Test Email

    Now you can also use mail from the command line with something like:

    $echo "test text" | mail -s "test mail content"

    The text “test text” is sent to the email address (you may also specify multiple addresses separated by spaces) with the subject “test mail content”. For more options type mail –help.

    Related articles

    comments powered by Disqus