LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-08-2013, 10:07 PM   #1
ostrosky.jeremiah
LQ Newbie
 
Registered: Aug 2011
Location: Pittsburgh, Pa
Distribution: Centos 6.4
Posts: 29

Rep: Reputation: Disabled
Cant get php mail() to send email


I'm not exactly 'new' to Linux but here's where I'm at. I recently upgraded the server in my house to Centos 6.3, 64bit (from Windoze) and it's taken a bit of getting used to. Basically the machine is used for a handful of purposes, including storing backups for all of my machines but more importantly it serves up my website. I'm using Apache 2.2 and PHP 5.3 (same setup I had on windows). I use a php script "FormToEmail" so users can submit requests via my website and they are sent to my gmail account (main email for that specific purpose). On the previous windows install, I used a simple program called Free SMTP Server. My question is, what is the easiest way for me to setup an outgoing only mail server just to handle the php script and deliver messages input into the html form. I've read some on ssmtp but can't seem to get it working. Suggestions anyone? I'd like to keep it as simple as possible as all it has to accomplish is to send the form information (which is gathered by the php script) to a single address, which is the same every single time.

Last edited by ostrosky.jeremiah; 03-08-2013 at 10:44 PM.
 
Old 03-08-2013, 11:27 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Welcome to LQ!

Check this out here.
 
Old 03-09-2013, 12:59 AM   #3
ostrosky.jeremiah
LQ Newbie
 
Registered: Aug 2011
Location: Pittsburgh, Pa
Distribution: Centos 6.4
Posts: 29

Original Poster
Rep: Reputation: Disabled
I've installed Postfix and configured it using this tutorial: http://www.unixmen.com/activate-and-...ntos-and-rhel/ and can successfully send emails from the command line using something like this: echo "test email" | mail myemailaddress@gmail.com I've also set (in the php.ini file) sendmail=/usr/sbin/sendmail -t -i and 'sendmail' is a symlink that points to /usr/sbin/sendmail.postfix, yet it appears the emails are still not being delivered via the web form. Again, they are successfully delivered when testing via the command line, but not when sent through the web form. Here is a link to the php FormToEmail that I'm using (and I've used before on other sites, hosted elsewhere).

http://formtoemail.com/FormToEmail.txt (text file of the actual code, I'm using it as-is, but of course with my email address, etc inserted (same php file I used when hosting the site on windows machine, so I know it's not faulty)

Any thoughts?
 
Old 03-09-2013, 01:19 AM   #4
ostrosky.jeremiah
LQ Newbie
 
Registered: Aug 2011
Location: Pittsburgh, Pa
Distribution: Centos 6.4
Posts: 29

Original Poster
Rep: Reputation: Disabled
Ok, I think I'm making progress but not sure where to go from here. However, this is what's appearing in /var/log/maillog:

Mar 9 02:13:13 centos postfix/sendmail[10243]: fatal: chdir /var/spool/postfix: Permission denied
 
Old 03-09-2013, 01:27 AM   #5
ostrosky.jeremiah
LQ Newbie
 
Registered: Aug 2011
Location: Pittsburgh, Pa
Distribution: Centos 6.4
Posts: 29

Original Poster
Rep: Reputation: Disabled
AWESOME. I figured it out with some help from our good friend Google, and a lot of reading. Turns out (as I'm very new to using SELINUX) that is was actually selinux preventing apache from sending the emails. I simply set 'setsebool -P httpd_can_sendmail 1' and VOILA! All is well and I'm now receiving emails from the web form. Can't believe it took me so long to realize the issue but like I said, this is the first distro I've used that uses selinux so... lesson learned, and mental note taken
 
  


Reply



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
Mail Server with : Postfix,dovecot. (Can send email, but can't receive email from internet mail) cparapat Linux - Server 1 08-16-2010 12:57 AM
Send mail to root but it send to other email smart_jija Solaris / OpenSolaris 5 07-01-2009 01:33 AM
Want to send mail with php mail() command - minimum config required? FeathersMc Linux - Server 2 10-26-2008 12:21 AM
command line email client to send mail to remote mail server dhanju Linux - Software 1 03-07-2008 06:37 AM
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 06:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:03 PM.

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