On Debian LAMP with different PHP based CMSs I use the MTA sSMTP to send email via an email proxy (Gmail); the emails I send are only contact-form inputs transferred from any such CMS to my own email account:

CMS contact-form input → Eail proxy (Gmail) → Main email account I use (also Gmail)

My sSMTP conf looks similar to this:

set -eu

read -p "Please paste your Gmail proxy email address: " \
read -sp "Please paste your Gmail proxy email password:" \
     gmail_proxy_email_password && echo

cat <<-EOF > /etc/ssmtp/ssmtp.conf

As you can see a file named /etc/ssmtp/ssmtp.conf will be created and will contain the email address and its account's password.

If the unlikely happens and an hacker finds out the email address and password I could be in a lot of trouble in cases I store payment information (I don't, I never did, and not planning to but still, it should be taken seriously).

How could I protect the aforementioned file? Maybe encrypting it somehow?

As of the moment I don't want to use an email server with configuring email DNS records, etc.

  • Don't use your gmail username and password... use an App Authorization Token instead... Commented Feb 11, 2019 at 18:10
  • Just put the App Password in the config file... in your configuration, you are using gmail as your mail server. You could use any text based MUA to perform the same task... such as mutt or any number of other options. Commented Feb 11, 2019 at 20:31
  • I'll appreciate any attempt to explain the two down votes.
    – user149572
    Commented Feb 15, 2019 at 3:05
  • I'm fairly certain that downvotes are anonymous ... In general I don't downvote unless the question is actually gibberish. ... Also, many of us are volunteering our time, at least I am, and life sometimes gets in the way of posting.... What information are you looking for in addition to the answer already written? Commented Feb 15, 2019 at 12:44
  • 1
    So seems the high vulnerability of copying the password (as long is it's not stored on my computer) won't go away anyway...
    – user149572
    Commented Feb 15, 2019 at 15:09

1 Answer 1


ssmtp has to use your login and password to send the mail. If it would be encrypted, ssmtp would have to decrypt it, so the hacker could do the same.

The file /etc/ssmtp/ssmtp.conf should have only the necessary permissions to allow ssmtp to access the file and you should secure your system to prevent unauthorized access.

See https://wiki.archlinux.org/index.php/SSMTP:

Because your email password is stored as cleartext in /etc/ssmtp/ssmtp.conf, it is important that this file is secure. By default, the entire /etc/ssmtp directory is accessible only by root and the mail group. The /usr/bin/ssmtp binary runs as the mail group and can read this file. There is no reason to add yourself or other users to the mail group.

If you use an app password (see also the web page referenced above) the credentials should not be usable for interactive login.

  • @JohnDoea This depends on your system and possible vulnerabilities. There is no absolute protection. You can only reduce the risk by securing your system as much as possible and installing all security updates. If an attacker can log in as a normal user who is able to send mail, he could use your mail account for sending spam without reading the credentials from ssmtp.conf.
    – Bodo
    Commented Feb 12, 2019 at 9:33
  • The web page I referenced in my answer also mentions app passwords. I added a note about this to the answer.
    – Bodo
    Commented Feb 12, 2019 at 10:20

You must log in to answer this question.