HOWTO: send mail from linux using gmail
Simplest way with minimal setup is sendemail utility:
# sudo apt-get install sendemail
# sendemail -vvv -f bearrailgun@gmail.com -t to@yandex.ru -u "topic" -m "The body of the message" -s smtp.gmail.com:587 -xu bearrailgun -xp mypassword
After that you will probably see:
Feb 06 00:13:21 pulsehouse sendemail[9038]: DEBUG => evalSMTPresponse() - Found SMTP error code: 534
Feb 06 00:13:21 pulsehouse sendemail[9038]: DEBUG => SMTP-AUTH: LOGIN authenticaion failed.
Feb 06 00:13:21 pulsehouse sendemail[9038]: ERROR => ERROR => SMTP-AUTH: Authentication to smtp.gmail.com:587 failed.
Check you gmail account. You will see a new mail with notification:
Google Account: sign-in attempt blocked
Let's see inside:
"...
If this was you
You can switch to an app made by Google such as Gmail to access your account (recommended) or change your settings at https://www.google.com/settings/security/lesssecureapps so that your account is no longer protected by modern security standards."
So follow this link https://www.google.com/settings/security/lesssecureapps and change Access for less secure apps to "Turn on"
Try again same sendemail command. Now works!
Feb 06 00:15:18 pulsehouse sendemail[9055]: Email was sent successfully! From: <bearrailgun@gmail.com> To: <to@yandex.ru> Subject: [test] Server: [smtp.gmail.com:587]
That's it.