mail function under Apache/PHP5
I'm running Opensuse Linux 10.2. I have a web page containing the PHP code
echo mail("abrahams@acm.org","test php mail","test with an echo"); When I look at the web page in Firefox (I assume the browser doesn't matter, though), this line turns into "1", indicating that the mail function succeeded. I could not find any error messages anywhere, including the system log. But nonetheless, I received no mail. How can I track this down? |
This can be tricky, but first, are you 100% sure your mail setup is correctly configured on that system?
Are you trying to localmail yourself, or do you expect the system to go out over a mail relay through the internet and then get through to you? If you run phpinfo() on that machine, what does it have under sendmail_path and the "Standard" section? What does Path to sendmail have set for it? Also, what is the content of the SMTP and smtp_port lines in the phpinfo screen? |
if sendmail is installed correctly on your system - it may be that the pop server does not accept emails from your local box because it cant resolve your ip or whatever reason...
|
> This can be tricky, but first, are you 100% sure your mail setup is correctly configured on that system?
The command mail abrahams@acm.org -s test this is a test ^D works as it should and I get the message. > Are you trying to localmail yourself, or do you expect the system to go out over a mail relay through the internet and then get through to you? > The latter. > If you run phpinfo() on that machine, what does it have under sendmail_path The default: "/usr/sbin/sendmail -t -i". And /usr/bin/sendmail exists and is executable by all. > and the "Standard" section? What does Path to sendmail have set for it? Same as above: /usr/sbin/sendmail -t -i > Also, what is the content of the SMTP and smtp_port lines in the phpinfo screen? SMTP: localhost smtp_port: 25 Does this info help? |
Quote:
|
Sendmail problem
I just tried
/usr/sbin/sendmail abrahams@acm.org this is the message. ^D and nothing was received. So how do I convince sendmail to send this message the same way that mail does? |
Quote:
From what you replied to the results in phpinfo() it seems your PHP setup is 100% fine, and your problems does not lie there... You might need to altery sendmail.cf (the sendmail sending / routing rules) to enable sendmail to work "directly". No idea how or what you will need to do though - PHP seems fine, and thats basically where my experience so far stops... |
Additional parameters
I think I know now what the problem is, by looking at my .mailrc file:
set from=abrahams@acm.org set smtp=smtp.comcast.net set smtp-auth-user=pwabrahams set smtp-auth-password=xxx Somehow I need to transmit the information in these lines to php. How can I do that? I'd guess it requires adding something to php.ini, which brings up another question: which copy of php.ini is the active one? I'm guessing it's /etc/php5/apache2/php.ini, but I'm not sure. I thought I might be able to do it by adding parameters to the sendmail call, but I can't find any sendmail parameters that carry this information. |
Hmm - I'm not sure but can't you add these in the "headers" that you send to the PHP mail() call? Although I'm not sure those types of parameters can be passed in the headers section of the mail() call, it does seem the best bet?
|
I'm no expert on this, but it seems that the headers carry information pertaining to the message, not the agents that handle it. I haven't found any way to put the ISP username/password information there.
I'm now investigating another path: setting up parameters to the SASL authenticator. There's some googlable stuff about it on the Web. But looking into it is drawing me into obscure corners of networking under Linux that I was hoping I would not have to deal with. |
as far as i know php on windows is usually cofigured to work with an external smtp server and on unix systems to work with internal sendmail. info regarding the smtp server does not belong to the mail headers.
take a look at php.net -> type "mail" into search box |
Here is the answer
I've solved this problem:), thanks in part to the fine advice that I found here:http://postfix.state-of-mind.de/patr...ilservers.html
Very briefly, here's the method given there (assuming that "sendmail" is a wrapper for postfix): 1. Assume the ISP access URL, username, and password are "smtp.isp.com", "uname", and "pwd". Append the line Code:
smtp.isp.com uname:pwd 2. Create the file /etc/postfix/sasl_passwd.db with the command Code:
postmap hash:/etc/postfix/sasl_passwd Code:
smtp_sasl_auth_enable = yes Code:
postfix reload Code:
sendmail_path = sendmail -t -i -f myaddr@myisp.net which will bounce and cause your mail not to be sent. |
All times are GMT -5. The time now is 08:44 PM. |