LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-31-2006, 04:05 PM   #1
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Rep: Reputation: 41
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?
 
Old 01-01-2007, 02:14 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
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?
 
Old 01-01-2007, 11:14 AM   #3
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,415

Rep: Reputation: 99
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...
 
Old 01-01-2007, 11:51 AM   #4
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Original Poster
Rep: Reputation: 41
> 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?
 
Old 01-01-2007, 11:56 AM   #5
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by j-ray
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...
If the problem is with the POP server, how could I determine that?
 
Old 01-01-2007, 12:01 PM   #6
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Original Poster
Rep: Reputation: 41
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?
 
Old 01-01-2007, 04:21 PM   #7
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
Quote:
Originally Posted by pwabrahams
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?
Hmm - I guess it might behave like this because mail calls sendmail through its queueing process (as far as I know) ?? You should have two sendmail process running, one is sendmail itself, one is the sendmail queue process. I'm guessing mail calls this queueing process in the "right" way to get sendmail to send out the mail correctly. Further guess might be that it prepends some form of routing information?

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...
 
Old 01-01-2007, 08:11 PM   #8
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Original Poster
Rep: Reputation: 41
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.
 
Old 01-02-2007, 12:27 AM   #9
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
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?
 
Old 01-02-2007, 11:49 AM   #10
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Original Poster
Rep: Reputation: 41
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.
 
Old 01-02-2007, 02:04 PM   #11
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,415

Rep: Reputation: 99
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
 
Old 01-09-2007, 04:30 PM   #12
pwabrahams
Member
 
Registered: Nov 2005
Location: Deerfield MA
Distribution: OpenSuSE, Kubuntu
Posts: 272

Original Poster
Rep: Reputation: 41
Smile 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
to the file /etc/postfix/sasl_passwd.

2. Create the file /etc/postfix/sasl_passwd.db with the command
Code:
postmap hash:/etc/postfix/sasl_passwd
3. Insert the lines
Code:
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
4. Reload postfix with
Code:
postfix reload
There's one more essential step for getting the mail command to work that does not involve postfix. In your php5.conf file, insert the line

Code:
sendmail_path = sendmail -t -i -f myaddr@myisp.net
Without this, the mail relay at your ISP will almost certainly attempt to send an acknowledgment,
which will bounce and cause your mail not to be sent.
 
  


Reply

Tags
opensuse, php5, sendmail


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
php5 compile woes: undefined function imagettftext BCarey Slackware 5 05-18-2007 11:42 PM
apache 2 with php5 and mysql5 jghalo Linux - Software 1 09-08-2006 03:22 PM
Strange problem with PHP5/MySQL update function gabebster Programming 9 04-06-2006 11:48 PM
help installing PHP5 for Apache blizunt7 Fedora 6 11-03-2005 10:59 AM
Apache and PHP5 Mogatu Linux - Software 3 06-17-2005 03:43 PM


All times are GMT -5. The time now is 04:42 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration