LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 01: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, 01: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: 343Reputation: 343Reputation: 343Reputation: 343
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, 01:39 PM   #3
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,261

Rep: Reputation: 297Reputation: 297Reputation: 297
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 01:44 PM.
 
Old 08-24-2011, 10:08 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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


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


All times are GMT -5. The time now is 12:59 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration