0

I have setup a server with the following settings:

CentOS release 6.3 (Final)
Kernel \r on an \m

Linux version 2.6.32-279.14.1.el6.x86_64 ([email protected]) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Tue Nov 6 23:43:09 UTC 2012

I have installed Qmail and Cron.

When I send an e-mail through a Webmin interface (using Qmail), the mail arrives. However, when I try to send an email through a php script, I get the following error message in /var/log/maillog:

Failed to create spool file /var/spool/exim/input//1V8rf1-0005w0-Jx-D: Permission denied
Cannot open main log file "/var/log/exim/main.log": Permission denied: euid=93 egid=93
exim: could not open panic log - aborting: see message(s) above

And in /var/log/virtualmin/[host]_error_log:

PHP Fatal error:  <br /><strong>Uncaught Error</strong> of type [Swift_ConnectionException] with message [Sending failed using mail() as PHP's default mail() function returned boolean FALSE

I seems like it is some kind of permission issue (or an issue with qmail and exim), however I am not able to solve it after researching for a few days now. I have Webmin and Virtualmin installed.

Some extra information on permissions:

$ ls -l /var/spool/exim/
total 32
drwxrwxrwx. 2 exim exim  4096 Oct 28  2012 db
drwxrwxrwx. 2 exim exim 24576 Aug  9 16:52 input
drwxrwxrwx. 2 exim exim  4096 Aug  9 16:52 msglog

$ ls -l /usr/sbin/exim
-rwsr-xr-x. 1 root root 1118184 Oct 28  2012 /usr/sbin/exim

Anybody suggestions? Help would be very much appreciated.

5
  • Why exactly did you install exim when you already have another MTA (qmail) installed?
    – etagenklo
    Aug 14, 2013 at 9:31
  • When installing cron, it automatically installs Exim...
    – Ab Co
    Aug 14, 2013 at 9:49
  • I'd suggest to remove exim again as there's no point in having 2 different MTAs on your system.
    – etagenklo
    Aug 14, 2013 at 10:33
  • I just removed exim (and automatically crontabs, since it is a dependancy). Ofcourse no issues concerning exim anymore, but it makes no difference, still not able to send mail via php. Error in /var/log/virtualmin/[host]_error_log stays the same and now my conjobs are not being executed.
    – Ab Co
    Aug 14, 2013 at 11:16
  • ll /var/log/exim/ :)
    – GioMac
    Aug 14, 2013 at 21:00

3 Answers 3

1

First Part The exim system requires that the spool directories and the log directories be writable by the exim user (the user the process runs as). The simple fix for exim would have been:

chown -R exim:exim /var/spool/exim /var/log/exim

Second Part Typically there is a /usr/sbin/sendmail wrapper which is really just a symlink to whatever provides "sendmail compatibility" on your system. When you installed exim, it created a symlink /usr/sbin/sendmail which ended up pointing to /usr/sbin/exim. [1] When you deleted the exim package, it removed the /usr/sbin/sendmail link. When cron starts up a job, it starts it and pipes it to /usr/sbin/sendmail. Since it no longer exists, the job fails to start completely.

The preferred fix is to use the "alternatives" system to update each of the mta components that the "alternatives" system manages:

# ls /etc/alternatives/ -l | grep mta
lrwxrwxrwx 1 root root 23 Aug 14 12:33 mta -> /usr/sbin/sendmail.exim
lrwxrwxrwx 1 root root 19 Aug 14 12:33 mta-mailq -> /usr/bin/mailq.exim
lrwxrwxrwx 1 root root 29 Aug 14 12:33 mta-mailqman -> /usr/share/man/man8/exim.8.gz
lrwxrwxrwx 1 root root 24 Aug 14 12:33 mta-newaliases -> /usr/bin/newaliases.exim
lrwxrwxrwx 1 root root 15 Aug 14 12:33 mta-pam -> /etc/pam.d/exim
lrwxrwxrwx 1 root root 19 Aug 14 12:33 mta-rmail -> /usr/bin/rmail.exim
lrwxrwxrwx 1 root root 19 Aug 14 12:33 mta-rsmtp -> /usr/bin/rsmtp.exim
lrwxrwxrwx 1 root root 18 Aug 14 12:33 mta-runq -> /usr/bin/runq.exim
lrwxrwxrwx 1 root root 22 Aug 14 12:33 mta-sendmail -> /usr/lib/sendmail.exim
# update-alternatives --config mta

There is 1 program that provides 'mta'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.exim

Enter to keep the current selection[+], or type selection number:

If that doesn't work for you (because qmail didn't configure itself as part of the "alternatives" system, then the simplest fix is to manually create that symlink:

cd /usr/sbin; ln -s qmail sendmail

[1] Technically, the "alternatives" system manages and created a symlink /usr/sbin/sendmail which pointed to /etc/alternatives/mta, which is a symlink to /usr/sbin/sendmail.exim. That /usr/sbin/sendmail.exim is also just a symlink to /usr/sbin/exim.

2
  • I will have a go with this tomorrow. I'll let you know. Thanks for now.
    – Ab Co
    Aug 14, 2013 at 14:48
  • OK, solved the chown exim issue. ls /etc/alternatives/ -l | grep mta is returning the exact same result as yours and ln -s qmail sendmail returns ln: creating symbolic link 'sendmail': File exists. Eventually it makes no difference. I am able to send mail through the Webmin interface (using qmail), but via php I have no luck whatsoever. Anybody any other suggestions?
    – Ab Co
    Aug 15, 2013 at 13:20
0

If you want to use built-in mail(), you will need to talk to the server administrator. It is possible to use an external SMTP server on Windows, but it has to be specified in the php.ini settings, and PHP's built-in functions don't support SMTP authentication.

The usual way is to either use a local mail server that in turn can talk to a "real" SMTP server with authentication, or use a mailing package like SwiftMailer that can connect to a 3rd party SMTP server like GMail directly.

-1

ln: creating symbolic link 'sendmail': File exists

This is because sendmail is already a symlink to /etc/alternatives/mta which is not required further.

Just remove the sendmail symlink using command:

cd /usr/sbin
rm -rf sendmail

And create a new link:

ln -s qmail sendmail

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .