LinuxQuestions.org
Visit Jeremy's Blog.
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 08-24-2011, 12:16 PM   #1
shongale
LQ Newbie
 
Registered: Jul 2010
Location: Eugene, Oregon USA
Distribution: CentOS 5.4
Posts: 5

Rep: Reputation: 0
mail() function in php does not work


I am having a problem with the mail() function in PHP 5.3.2, I am running CentOS 6 with Apache 2.2.15
My problem is I am totally confused.
Do I need to have postfix and DoveCot working before the smtp address I configured in /etc/php.ini will work?
I have an smtp address configured in php.ini. What else do I need to do?
Any help is greatly appreciated!!
 
Old 08-24-2011, 12:34 PM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by shongale View Post
I am having a problem with the mail() function in PHP 5.3.2, I am running CentOS 6 with Apache 2.2.15
My problem is I am totally confused.
Do I need to have postfix and DoveCot working before the smtp address I configured in /etc/php.ini will work?
have you used PHP on a Windows host before? That's where the SMTP parameters in php.ini are used, because Windows doesn't have an MTA (Mail Transfer Agent) integrated and must connect directly to an external MTA - typically an SMTP server.

Unix-like system usually do have an MTA, often postfix, that handles all SMTP communication on its own.

Quote:
Originally Posted by shongale View Post
I have an smtp address configured in php.ini. What else do I need to do?
Any help is greatly appreciated!!
On Unix/Linux, PHP won't even look at the SMTP parameters in php.ini, but rather at the sendmail_path. That is where you tell PHP which MTA you are using and where its executable is stored. So, yes, you must have a working MTA like postfix.
Actually, I don't understand either why you can't optionally have direct SMTP contact with PHP even on Linux.

Dovecot is completely out of this game, by the way, that's an MDA, a Mail Delivery Agent. It deals with *incoming* mail.

[X] Doc CPU
 
Old 08-24-2011, 12:39 PM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
Hi

The SMTP address in php.ini is for Windows only. On Linux, PHP uses the system's MTA (mail transfer agent) to send email. For postfix, you set the SMTP address by editing "/etc/postfix/main.cf" - set "relayhost = ip-number" and restart postfix. Also, you can usually check "/var/log/mail.log" or "/var/log/mail.err" if it doesn't work.

Edit:
I'm a slow typer...

Also, another option is to use to use PEAR's mail system. Then you can bypass the system's MTA, and send it directly to the SMTP server you want. Example here:

http://email.about.com/od/emailprogr...entication.htm

Last edited by Guttorm; 08-24-2011 at 12:44 PM.
 
Old 08-24-2011, 09:08 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I think the default on Centos/RHEL would be sendmail, its probably already setup.
However, you can use this page to check/amend http://linuxhelp.blogspot.com/2005/0...agent-mta.html
 
  


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() function in php ramzaher Linux - Newbie 4 04-29-2011 02:03 AM
Gmail does not work for receiving mail through function MAIL() ShaiMagal Linux - Server 2 09-07-2010 09:41 PM
PHP Mail function phantom_cyph Programming 6 05-15-2008 11:45 PM
PHP Mail() function doesn't work Messiadbunny Linux - Software 4 06-11-2005 04:40 AM
How does the mail function work(PHP) Alexander.s Programming 1 05-15-2005 09:02 AM

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

All times are GMT -5. The time now is 03:47 AM.

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