Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-13-2013, 01:04 PM   #1
LQ Newbie
Registered: Feb 2007
Posts: 28

Rep: Reputation: 0
Can't send php mail() on ubuntu server

Hi, I am unsure if this has been answered but searching proves an enorm load and I can't really find anything usefull to my problem so here goes.

I setup a ubuntu server 12.04 and installed php5.4 apache2, phpmyadmin and basically everything I need for a webserver (which is the main use) I also installed sendmail
sudo apt-get install sendmail
Now, I try to install a CMS on my webserver, and that seems to work, EXCEPT when I ask it to send a verification email, or any email actually, it dosen't send anything? (no error messages either)

I am unsure what I haven't setup right. (Was looking in php.ini and saw the path for sendmail wasen't set, but what path is right to use if this is it?)

I do not need a fully funktional webserver at any point, I just need my php to be able to send emails out (maybe through a gmail if that is easier?)

If anyone have a guide or an explanation to help me clear this problem I will be very happy.
Old 11-13-2013, 02:56 PM   #2
Registered: Jan 2010
Distribution: Fedora 19
Posts: 83

Rep: Reputation: 3
Selinux may cause the issue, to verify run:

getsebool -a | grep mail

If it displays as bellow it is selinux:

allow_postfix_local_write_mail_spool --> off

To enable httpd to send mail run this

setsebool -P httpd_can_sendmail on

This will allow the httpd to send emails, as when you use php mail().

To verify its working, send a test email to you local account.
Old 11-13-2013, 06:34 PM   #3
LQ Newbie
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 0
Thanks! I will try that in just a moment, right now I got so frustrated so I tried a completely fresh install, just in case I messed something up :P (I don't have a great temper)
Old 11-13-2013, 11:33 PM   #4
LQ Newbie
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 0
All I get from the grep command is:

The program 'getsebool' is currently not installed.  You can install it by typing:
apt-get install selinux-utils
I do not know what getsebool is, but I will read up on it so I can understand it better.

Would I really need this to make sendmail work?

(running ubuntu server 12.04 that is?)
Old 11-14-2013, 12:28 AM   #5
LQ Newbie
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 0
I can't see why there is no easy way to make mail() work on apache

alot of people report that just by installing sendmail it works, I can't make that work at all.

tried postfix and nullmailer too, without luck.
Old 11-14-2013, 01:17 AM   #6
Senior Member
Registered: Mar 2012
Posts: 1,522

Rep: Reputation: 399Reputation: 399Reputation: 399Reputation: 399
Well, just chucking a whole lot of engine parts into a car does not make it work either.
It has to be assembled and connected in a sensible fashion.

Set up your MTA and test it is working (plenty of guides at the end of your search engine - ask if there is something specific you don't get).

THEN check your php mail config to ensure it is using the local MTA.

(OR just reconfigure it to use an external one - gmail or such - but there will be extra steps for configuring authentication etc.)
Old 11-14-2013, 03:31 PM   #7
LQ Newbie
Registered: Feb 2007
Posts: 28

Original Poster
Rep: Reputation: 0
I tried severel guides for postfix and sendmail, but I am unable to make anyone work, and I am really at a limit here. I would love to authenticate googles smtp server, but that dosen't seem to wanna work.

I will try some more guides to see if anything helpes, and if I still am stuck, I will pick one that feels the best and come back to specify it a bit more.
(maybe you have a guide/application you can suggest?)


php5, sendmail, ubuntu 12.04

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send mail using PHP mail function On apache server kiran.ursal Linux - Server 2 04-29-2013 04:21 AM
Ubuntu mail server stopped recieving mail. will send. Ubuntu 9 ISPconfig3 Postfix 255 kejxero Linux - Server 0 02-07-2010 07:57 PM
Can send mail, but can't receive on Ubuntu Server 9.04 with Postfix Jamie Kugelmann Linux - Server 22 12-23-2009 07:38 AM
Want to send mail with php mail() command - minimum config required? FeathersMc Linux - Server 2 10-26-2008 01:21 AM
Help needed to send mail using a remote smtp server with php s1mpl1c1ty Programming 4 09-19-2005 01:53 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration