Quantcast
Channel: How to send mail from the command line? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 18

Answer by Aquarius_Girl for How to send mail from the command line?

$
0
0

Run:

sudo apt-get install ssmtp
sudo -H gedit /etc/ssmtp/ssmtp.conf

The following needs to be added there:

# The user that gets all the mails (UID < 1000, usually the admin)
root=yourusernameofgmail@gmail.com

# The mail server (where the mail is sent to), both port 465 or 587 should be acceptable
# See also https://support.google.com/mail/answer/78799
mailhub=smtp.gmail.com:587

# The address where the mail appears to come from for user authentication.
rewriteDomain=gmail.com

# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes

# Username/Password
AuthUser=yourusernameofgmail
AuthPass=yourGmailPassowrd
AuthMethod=LOGIN

# Email 'From header's can override the default domain?
FromLineOverride=yes

Run:

sudo -H gedit /etc/ssmtp/revaliases

Enter there:

root:yourusernameofgmail@gmail.com:smtp.gmail.com:587

Enable "less secure apps" on Gmail:
https://support.google.com/accounts/answer/6010255?hl=en

Test it by running the following on terminal:

echo "Body of mail is abc" | mail -s "Subject is xyz" "someusername@gmail.com"`

Viewing all articles
Browse latest Browse all 18

Trending Articles