I'm having some trouble getting SSMTP to let me send email as a regular user. When I set up this machine ~a year ago, I'd used Arch's instructions to set up security, but that apparently broke silently at some point with (I assume) an update, and I just realized that I haven't been getting email from cron and whatnot. I'd rather not have to hope that I notice when ssmtp updates and go change everything manually.

I'm getting what looks like a classic permission error:

$ echo "This is a test" | mail -s "Subject" <my email>
send-mail: Cannot open mailhub:25
Can't send mail: sendmail process failed with error code 1

This works perfectly fine when I run mail with sudo. However, my permissions look fine:

$ sudo ls -l /usr/sbin/ssmtp 
-rwxr-xr-x 1 root root 39784 Jul 14  2014 /usr/sbin/ssmtp
$ sudo ls -l /etc/ssmtp/ssmtp.conf
-rw-r----- 1 root root 699 Dec 28 16:35 /etc/ssmtp/ssmtp.conf

I've added my user to the "root" group, which seems little iffy, although I'd tried using the "mail" group earlier:

$ groups
root mail [...]

The frustrating part is that I've got a ubuntu box sitting here with what looks like exactly the same configuration, except that it works. What the heck am I doing wrong? [This machine is running Debian "stretch", ssmtp package version 2.64-8+b2]

Edit- As requested, I tried using mail in verbose mode, which didn't yield any additional output (?)

$ echo "Test" | mail -v -s "Test" my@email.com
send-mail: Cannot open mailhub:25
Can't send mail: sendmail process failed with error code 1
  • a strace might indicate what send-mail is doing right before issuing that error
    – thrig
    Dec 28 '17 at 23:14
  • I'm sorry, I have no idea how to use strace :/ I have no significant programming (or debugging) experience.
    – Decoherent
    Dec 29 '17 at 1:08
  • Please add debugging output by pasting the output of: echo test|mail -v -s "test" your@mail.com
    – Jan
    Dec 31 '17 at 18:07

If you used those Arch configuration instructions the part you're missing after a Debian upgrade is that there is nothing to tell Debian to reapply the setgid bit. Run these two commands (or use the script /root/bin/ssmtp-set-permissions if you created that)

chown :ssmtp /usr/bin/ssmtp
chmod g+s /usr/bin/ssmtp

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.