LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mail() function in php does not work (https://www.linuxquestions.org/questions/linux-newbie-8/mail-function-in-php-does-not-work-899217/)

shongale 08-24-2011 12:16 PM

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!!:D

Doc CPU 08-24-2011 12:34 PM

Hi there,

Quote:

Originally Posted by shongale (Post 4452292)
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 (Post 4452292)
I have an smtp address configured in php.ini. What else do I need to do?
Any help is greatly appreciated!!:D

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

Guttorm 08-24-2011 12:39 PM

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

chrism01 08-24-2011 09:08 PM

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


All times are GMT -5. The time now is 10:13 PM.