I'm just starting with my own Virtual Server (and Linux). I've an apache2 and a few WordPress sites. I need to send mails via PHP (contact forms). I managed to install ssmtp with the help of a few tutorials. It sends mail with an gmail account. I'm not sure about the right permissions of the ssmtp.conf:

When I chmod 600 /etc/ssmtp/ssmtp.conf I cant't send mails from the commandline, php-contact forms are also not working.

When I chmod 640 /etc/ssmtp/ssmtp.conf I can send mails from the commandline, but php-contact forms are not working.

When I chmod 666 /etc/ssmtp/ssmtp.conf I can't send mails from the commandline and php-contact forms are working fine.

Obviously I would like to stay with 666, but I'm not sure if this could be a security problem.

  • have you tried 644 ? (allow anyone to read) – Archemar Oct 22 '14 at 14:13
  • gksudo gedit /etc/ssmtp/ssmtp.conf – Elba Yass Mar 17 '17 at 19:53

It appears that you have your Gmail password in the configuration file so you would want the the third number to be 0 (No permissions to Others). Ideal is 640. You can change the ownership of the configuration file (using the command chown) e.g. chown root:mail /etc/ssmtp/ssmtp.conf.

You can send from the command line using sudo or as root. Your web server user also need to be a member of group mail. Or you can change that to root:www-data if the user group of the web server is www-data.

| improve this answer | |
  • 1
    It's working fine with 640 after changing the ownership to root:www-data. Thank's for your help! – Albrecht Oct 23 '14 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.