I found the following related questions on the stackexchange network:
- stackoverflow - Connecting to smtp.gmail.com via command line
- serverfault - Using nc.exe (NetCat) to send emails to secured SMTP server (TLS)
- stackoverflow - How to send email using simple SMTP commands via Gmail?
But except for the last one, they are all talking about Windows or Debian and specify software that I've been unable to find for RHEL/CentOS (e.g.
The last linked solution seems okay (as in, may possibly work on CentOS) but it requires the password to be entered in cleartext on the command line (in a perl one-liner) to get a base64 encoded string, and then requires the base64 encoded string to be entered later on during a run of openssl. This is relatively insecure as even assuming I've disabled the
bash history for that command, the base64 string isn't encrypted and is itself stored in the terminal history, the clipboard and who knows where else. Also, whenever possible I work in a virtual terminal, and thus I would prefer to have a solution which doesn't require copy and paste at all.
I would also prefer to have a solution which would work even in a business environment—i.e. when my email password is entered, it shouldn't even be echoed to the screen (just like a
So again, the exact question is: How can I safely send an email from a gmail account via the command line on CentOS?