title: What is the proper permission configuration of sendmail
body: <p>This question comes from a problem much similar to this <a href="https://serverfault.com/questions/320607/ubuntu-jaunty-sendmail-php-mail-premission-errors">https://serverfault.com/questions/320607/ubuntu-jaunty-sendmail-php-mail-premission-errors</a></p>
  
  <p>But those answers don't solve my problem</p>
  
  <p>I have a php application which is using PHPMailer to send emails. </p>
  
  <p>I installed sendmail on my ubuntu 12.04 LTS with</p>
  
  <pre><code>sudo apt-get install sendmail
  sudo sendmailconfig
  </code></pre>
  
  <p>But the application failed to send any mail. In the mail.err it says:</p>
  
  <pre><code>Apr 14 00:31:42 AY sendmail[32241]: NOQUEUE: SYSERR(www-data): can not chdir(/var/spool/mqueue-client/): Permission denied
  </code></pre>
  
  <p>while www-data is the username of apache2.</p>
  
  <p>Then I followed some guides from internet, add www-data to smmsp group:</p>
  
  <pre><code>sudo usermod -a -G smmsp www-data
  </code></pre>
  
  <p>Now when I </p>
  
  <pre><code>groups www-data
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>www-data : www-data smmsp
  </code></pre>
  
  <p>and the line in the /etc/group is:</p>
  
  <pre><code>smmsp:x:114:www-data
  </code></pre>
  
  <p>Also I made sure of access to /var/spool/mqueue-client/ is 770</p>
  
  <pre><code>/var/spool]$ ls -la
  total 28
  drwxr-xr-x  7 root   root  4096 Apr  2 00:21 .
  drwxr-xr-x 11 root   root  4096 Apr 14 03:30 ..
  drwxr-xr-x  5 root   root  4096 Aug  6  2012 cron
  lrwxrwxrwx  1 root   root     7 Aug  6  2012 mail -&gt; ../mail
  drwxr-s---  2 smmta  smmsp 4096 Apr 14 06:25 mqueue
  drwxrws---  2 smmsp  smmsp 4096 Apr 14 06:25 mqueue-client
  drwxr-xr-x  2 root   root  4096 Apr 13  2012 plymouth
  drwxr-xr-x  2 syslog adm   4096 Mar 31  2012 rsyslog
  
  /]$ ls -ld /var/spool/mqueue-client/ /usr/sbin/sendmail
  lrwxrwxrwx 1 root  root    26 Apr  2 00:21 /usr/sbin/sendmail -&gt; /etc/alternatives/sendmail
  drwxrws--- 2 smmsp smmsp 4096 Apr 14 06:25 /var/spool/mqueue-client/
  </code></pre>
  
  <p>But I still get error when I try to send mail</p>
  
  <pre><code>Apr 14 03:26:57 AY sendmail[6131]: NOQUEUE: SYSERR(www-data): can not write to queue directory /var/spool/mqueue-client/ (RunAsGid=33, required=114): Permission denied
  </code></pre>
  
  <p>while 33 is gid of www-data</p>
  
  <pre><code>www-data:x:33:
  </code></pre>
  
  <p>What should I do to get sendmail work but keep the security?
  Further, What is the proper permission configuration (user, group, and directories access etc) of sendmail in a production environment ?</p>