SID-01592: Cannot send an email with selinux enforcing.
| Status: |
Answered |
TWiki version: |
5.1.2 |
Perl version: |
5.10.1 |
| Category: |
CategoryEmail |
Server OS: |
CentOS 6.3 kernel 2.6.32-279.14.1.el6.x86_64 |
Last update: |
13 years ago |
When trying to send an email I got the following message
ERROR: Can't send mail using Net::SMTP. Can't connect to 'mars.lereta.com' - 0, Permission denied, Net::SMTP: connect: Permission denied at /var/www/twiki/lib/TWiki/Net.pm line 515.
Too many failures sending mail %PARAM2% %PARAM3% %PARAM4%
(I expanded the error message in Net.pm with $?, $! and $@)
This made absolutely no sense to me. I could use Net::SMTP from a standalone program as apache and it worked fine. When I used a sniffer (thsark) to capture the traffic between scadev04 and mars during the attempted send from TWiki, I saw nothing on port 25.
I finally traced the problem to selinux. The settings httpd_can_sendmail and httpd_can_network_connect were both set to "off". I changed them to "on" and emails are now being sent as expected.
$ sudo setsebool -P httpd_can_sendmail on
$ sudo setsebool -P httpd_can_network_connect on
--
StephenCarville - 2012-11-28
Discussion and Answer
I guess I answered in the description
--
StephenCarville - 2012-11-28
Thank you Stephen! I updated the
TWikiSiteTools doc and the
{SMTP}{MAILHOST} configure setting accordingly.
--
PeterThoeny - 2012-11-29
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.