php-general Digest 23 Oct 2009 06:24:38 -0000 Issue 6405

Topics (messages 299229 through 299248):

Re: Trapping failure of file_get_contents()
        299229 by: Robert Cummings
        299230 by: Gerardo Benitez
        299240 by: Marshall Burns

Re: Spam opinions please
        299231 by: Philip Thompson
        299239 by: Gary
        299241 by: Ashley Sheridan

Limit query/function time
        299232 by: Philip Thompson
        299233 by: Eddie Drapkin
        299234 by: Phpster
        299235 by: Philip Thompson
        299236 by: Philip Thompson

php mail() function
        299237 by: James Prentice
        299238 by: LinuxManMikeC
        299242 by: James Prentice
        299244 by: Paul M Foster
        299245 by: Shawn McKenzie
        299246 by: Paul M Foster
        299247 by: kranthi

input form save and display conflict
        299243 by: PJ

Is there any way to get all the function name being called in a process?
        299248 by: Satya Narayan Singh

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Marshall Burns wrote:
Robert and others,

I made that change in the code. It still does not trap the failure. I
believe the reason is that the script is timing out while
file_get_contents() is sitting there waiting for input. The problem is that
the function never returns, so there is no return value to check. What I
need is to get file_get_contents() to quit trying before the script timeout
limit is reached, so I can catch the failure and try again. If that cannot
be done, then I need to get the shutdown function to work.

For reference, my original question is at http://marc.info/?l=php-general&m=125622597723923&w=2 .

If you need more control then I suggest you switch from file_get_contents() to using curl to retrieve the page. You can then set your timeout criteria.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
Hi Marshall,

the function file_get_contents may have problem with large files.

You could try get the file using "fread" and feof.

Here i put a example



$contents = '';
while(!feof($stream)){
    $contents .= fread($stream, 8192);
}


Gerardo Benitez.





On Thu, Oct 22, 2009 at 12:38 PM, Marshall Burns <listma...@mburns.com>wrote:

> I have a script that downloads a sequence of files online. Every hundred
> files or so, it fails with:
>
>
>
> ==========================
>
> Warning: file_get_contents(<URL>) []: failed to open stream: A connection
> attempt failed because the connected party did not properly respond after a
> period of time, or established connection failed because connected host has
> failed to respond. in <script>.php on line <number>
>
> Fatal error: Maximum execution time of 30 seconds exceeded in <script>.php
> on line <number>
>
> ==========================
>
>
>
> I have tried to trap this so that I could loop back and let the script try
> the access again. Failing that, I've also tried to get a shutdown function
> to give me a restart link. The code for this is:
>
>
>
> ==========================
>
> $bWorking = true;
>
>
>
>            .
>
>            $bDone = false;
>
>            while(! $bDone)
>
>               {$sFil = file_get_contents($sURL);
>
>                        if($sFil)
>
>                           {$sFileSize = file_put_contents('image/' . $sID .
> '.jpg', $sFil);
>
>                                    $bDone = true;}
>
>                          else
>
>                           {echo('<br>DL error on ' . $sURL);
>
>                                    $sFileSize = 'DL error';
>
>                                    set_time_limit(30);}
>
>                        echo(', got ' . $sFileSize);
>
>                        }
>
>            .
>
>
>
> $bWorking = false;
>
>
>
> register_shutdown_function('ReadFileTimeout');
>
> function ReadFileTimeout()
>
>            // Provide a link to restart processing after a timeout in
> file_get_contents().
>
>   {global $bWorking, $sParameters;
>
>            if($bWorking)
>
>                        echo('<p><a HRef="<script>.php?parameters=' .
> $sParameters . '" target="_blank">Restart</a>');
>
>            }
>
> ==========================
>
>
>
> None of that is working. I guess the loop doesn't work because the warning
> is emitted after the script has already been aborted by the timeout. But in
> that case, the shutdown function should kick in, but the link is not being
> output.
>
>
>
> So two questions:
>
>            (a) Is there a way to get file_get_contents() to stop trying
> before the script time limit is reached, so that my loop could work?
>
>            (b) Why is the shutdown function not working?
>
>
>
> Thanks for your help.
>
>
>
> Marshall
>
>
>
>
>
>
>
>
>
>
>
>


-- 
Gerardo Benitez

--- End Message ---
--- Begin Message ---
> If you need more control then I suggest you switch from 
> file_get_contents() to using curl to retrieve the page. You can then set 
> your timeout criteria.

Bingo! That appears to have done it. In fact, not only did it solve the
timeout problem raised in 
http://marc.info/?l=php-general&m=125622597723923&w=2
but it also seems to have accidentally solved the separate problem of
mysterious access violation errors raised in 
http://marc.info/?l=php-general&m=125601395731668&w=2

Apparently, not only does curl give me control over execution time of the
function, but it seems to do its file access in a cleaner way somehow. I say
this not only because the access violation errors have gone away, but also
because the frequency of failed access attempts is much lower now than when
I was using file-get-contents().

Thank you big time, Robert.

If anyone would like to see, the function that I wrote to replace both
file-get-contents() and simplexml_load_file() is below. For
file-get-contents(), it can optionally do the job of an additional
file-put-contents(). In the case of simplexml_load_file(), it works by
passing the downloaded file as a string to simplexml_load_string().

If anyone sees any problems or weaknesses with how this is written, please
do let me know. (Please be sure to include me in the recipients because I'm
going to unsubscribe from the list now.)

Thanks all for your help.


====================================================================

function GetFile($sURLin, $sFileOut)
   {// Get an online file and either return it as a string or write it to a
file and return the file size.
        $oChandle = curl_init($sURLin);
        if($sFileOut == '')
           {$bWriteFile = false;
                curl_setopt($oChandle, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($oChandle, CURLOPT_BINARYTRANSFER, true);}
          else
           {$bWriteFile = true;
                $oFilePtr = fopen($sFileOut, 'w');
                curl_setopt($oChandle, CURLOPT_FILE, $oFilePtr);}
        curl_setopt($oChandle, CURLOPT_HEADER, 0);
        curl_setopt($oChandle, CURLOPT_CONNECTTIMEOUT, 5);
        $bGetIt = true;
        while($bGetIt)
           {$sRetVal = curl_exec($oChandle);
                if($sRetVal === false) 
                   {sWarning('DL error on ' . $sURLin);
                        set_time_limit(30);
                        sleep(1);}
                  else
                   {if($bWriteFile) 
                        $sRetVal = 
                                curl_getinfo($oChandle,
CURLINFO_SIZE_DOWNLOAD);
                        $bGetIt = false;}
                }
        curl_close($oChandle);
        if($bWriteFile) fclose($oFilePtr);
        return($sRetVal);
        }



-----Original Message-----
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Thursday, October 22, 2009 11:21
To: Marshall Burns
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] Trapping failure of file_get_contents()

Marshall Burns wrote:
> Robert and others,
> 
> I made that change in the code. It still does not trap the failure. I
> believe the reason is that the script is timing out while
> file_get_contents() is sitting there waiting for input. The problem is
that
> the function never returns, so there is no return value to check. What I
> need is to get file_get_contents() to quit trying before the script
timeout
> limit is reached, so I can catch the failure and try again. If that cannot
> be done, then I need to get the shutdown function to work.
> 
> For reference, my original question is at 
> http://marc.info/?l=php-general&m=125622597723923&w=2 .

If you need more control then I suggest you switch from 
file_get_contents() to using curl to retrieve the page. You can then set 
your timeout criteria.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP



--- End Message ---
--- Begin Message ---
On Oct 20, 2009, at 1:48 PM, Gary wrote:

NO I have not, I think my issue is I hate when I run across one, it usually takes me more than one try to actually figure out what the charactor is, so
hence my disdain.


GAry

Here are some captchas:

"What's three minus two?"
"Which word is listed first in the dictionary: apple, banana, pizza?"
"Add 4 plus 5"

Create a list of simple questions that only humans can answer. I find these to be less annoying.

~Philip


"Paul M Foster" <pa...@quillandmouse.com> wrote in message
news:20091020184001.gi3...@quillandmouse.com...
On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:

I have several sites that are getting hit with form spam. I have the
script
set up to capture the IP address so I know from where they come. I found
a
short script that is supposed to stop these IP addresses from accessing
the
form page, it redirects the spammer to another page (I was going to
redirect
to a page that has lots of pop-ups, scantily clad men and offers of joy
beyond imagination), but someone suggested I redirect to the Federal
Trade
Commission or perhpas the FBI.

Any thoughts on the script and its effectivness?

<?php
$deny = array("111.111.111", "222.222.222", "333.333.333");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
  header("location: http://www.google.com/";);
  exit();
} ?>Gary


Have you tried CAPTCHA?

Paul

--- End Message ---
--- Begin Message ---
I have always thought that by putting some simple, readable ttext into a 
graphic (eg.apple) and asking people to type it in a space, that would work, 
but that does not stop the humans..

Gary


"Philip Thompson" <philthath...@gmail.com> wrote in message 
news:9bf33458-4a91-4a23-bcb8-ebe13269f...@gmail.com...
> On Oct 20, 2009, at 1:48 PM, Gary wrote:
>
>> NO I have not, I think my issue is I hate when I run across one, it 
>> usually
>> takes me more than one try to actually figure out what the charactor  is, 
>> so
>> hence my disdain.
>>
>>
>> GAry
>
> Here are some captchas:
>
> "What's three minus two?"
> "Which word is listed first in the dictionary: apple, banana, pizza?"
> "Add 4 plus 5"
>
> Create a list of simple questions that only humans can answer. I find 
> these to be less annoying.
>
> ~Philip
>
>
>> "Paul M Foster" <pa...@quillandmouse.com> wrote in message
>> news:20091020184001.gi3...@quillandmouse.com...
>>> On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:
>>>
>>>> I have several sites that are getting hit with form spam.  I have  the
>>>> script
>>>> set up to capture the IP address so I know from where they come.   I 
>>>> found
>>>> a
>>>> short script that is supposed to stop these IP addresses from 
>>>> accessing
>>>> the
>>>> form page, it redirects the spammer to another page (I was going to
>>>> redirect
>>>> to a page that has lots of pop-ups, scantily clad men and offers  of 
>>>> joy
>>>> beyond imagination), but someone suggested I redirect to the Federal
>>>> Trade
>>>> Commission or perhpas the FBI.
>>>>
>>>> Any thoughts on the script and its effectivness?
>>>>
>>>> <?php
>>>> $deny = array("111.111.111", "222.222.222", "333.333.333");
>>>> if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
>>>>   header("location: http://www.google.com/";);
>>>>   exit();
>>>> } ?>Gary
>>>>
>>>
>>> Have you tried CAPTCHA?
>>>
>>> Paul
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4534 (20091022) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus signature 
database 4534 (20091022) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
On Thu, 2009-10-22 at 19:39 -0400, Gary wrote:

> I have always thought that by putting some simple, readable ttext into a 
> graphic (eg.apple) and asking people to type it in a space, that would work, 
> but that does not stop the humans..
> 
> Gary
> 
> 
> "Philip Thompson" <philthath...@gmail.com> wrote in message 
> news:9bf33458-4a91-4a23-bcb8-ebe13269f...@gmail.com...
> > On Oct 20, 2009, at 1:48 PM, Gary wrote:
> >
> >> NO I have not, I think my issue is I hate when I run across one, it 
> >> usually
> >> takes me more than one try to actually figure out what the charactor  is, 
> >> so
> >> hence my disdain.
> >>
> >>
> >> GAry
> >
> > Here are some captchas:
> >
> > "What's three minus two?"
> > "Which word is listed first in the dictionary: apple, banana, pizza?"
> > "Add 4 plus 5"
> >
> > Create a list of simple questions that only humans can answer. I find 
> > these to be less annoying.
> >
> > ~Philip
> >
> >
> >> "Paul M Foster" <pa...@quillandmouse.com> wrote in message
> >> news:20091020184001.gi3...@quillandmouse.com...
> >>> On Tue, Oct 20, 2009 at 02:31:53PM -0400, Gary wrote:
> >>>
> >>>> I have several sites that are getting hit with form spam.  I have  the
> >>>> script
> >>>> set up to capture the IP address so I know from where they come.   I 
> >>>> found
> >>>> a
> >>>> short script that is supposed to stop these IP addresses from 
> >>>> accessing
> >>>> the
> >>>> form page, it redirects the spammer to another page (I was going to
> >>>> redirect
> >>>> to a page that has lots of pop-ups, scantily clad men and offers  of 
> >>>> joy
> >>>> beyond imagination), but someone suggested I redirect to the Federal
> >>>> Trade
> >>>> Commission or perhpas the FBI.
> >>>>
> >>>> Any thoughts on the script and its effectivness?
> >>>>
> >>>> <?php
> >>>> $deny = array("111.111.111", "222.222.222", "333.333.333");
> >>>> if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
> >>>>   header("location: http://www.google.com/";);
> >>>>   exit();
> >>>> } ?>Gary
> >>>>
> >>>
> >>> Have you tried CAPTCHA?
> >>>
> >>> Paul
> >
> > __________ Information from ESET Smart Security, version of virus 
> > signature database 4534 (20091022) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://www.eset.com
> >
> >
> > 
> 
> 
> 
> __________ Information from ESET Smart Security, version of virus signature 
> database 4534 (20091022) __________
> 
> The message was checked by ESET Smart Security.
> 
> http://www.eset.com
> 
> 
> 
> 
> 


Won't stop a bot worth it's salt either, hence the need for more complex
and confusing captchas. The best way to stop spam, is to use linguistic
testing on the content being offered, which protects against bot and
human spammer alike.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Hi all.

I'm running into a random issue where sometimes it take several minutes (up to 10 or 15) to complete a query. According to 1 or 2 references, this may be a mysql bug. These links explain the similar problem I'm experiencing:

http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully queried (in milliseconds) approximately 50,000 times before it took several minutes to query, which hung all the other processes on the database. Because it occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP? E.g., when I call mysql_query() and it takes 30 seconds, then quit processing that function and continue on. I know I could set_time_limit () to a specific time, but that would cause a fatal error... and I want to be able to catch it.

Any thoughts on what direction I should go? Also, I'm going to do some research to see if a newer version of mysql has fixed this bug. We're running 5.0.45.

Thanks,
~Philip

--- End Message ---
--- Begin Message ---
On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson <philthath...@gmail.com> wrote:
> Hi all.
>
> I'm running into a random issue where sometimes it take several minutes (up
> to 10 or 15) to complete a query. According to 1 or 2 references, this may
> be a mysql bug. These links explain the similar problem I'm experiencing:
>
> http://forums.mysql.com/read.php?24,57257
> http://forum.percona.com/s/m/790/
>
> I did some testing yesterday and this 1 sql statement successfully queried
> (in milliseconds) approximately 50,000 times before it took several minutes
> to query, which hung all the other processes on the database. Because it
> occurs successfully so many times, I know the query is good.
>
> Is it possible to set a time limit on a single function in PHP? E.g., when I
> call mysql_query() and it takes 30 seconds, then quit processing that
> function and continue on. I know I could set_time_limit() to a specific
> time, but that would cause a fatal error... and I want to be able to catch
> it.
>
> Any thoughts on what direction I should go? Also, I'm going to do some
> research to see if a newer version of mysql has fixed this bug. We're
> running 5.0.45.
>
> Thanks,
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.

--- End Message ---
--- Begin Message ---
Have you run an explain plan on the query?

Bastien

Sent from my iPod

On Oct 22, 2009, at 4:14 PM, Philip Thompson <philthath...@gmail.com> wrote:

Hi all.

I'm running into a random issue where sometimes it take several minutes (up to 10 or 15) to complete a query. According to 1 or 2 references, this may be a mysql bug. These links explain the similar problem I'm experiencing:

http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully queried (in milliseconds) approximately 50,000 times before it took several minutes to query, which hung all the other processes on the database. Because it occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP? E.g., when I call mysql_query() and it takes 30 seconds, then quit processing that function and continue on. I know I could set_time_limit() to a specific time, but that would cause a fatal error... and I want to be able to catch it.

Any thoughts on what direction I should go? Also, I'm going to do some research to see if a newer version of mysql has fixed this bug. We're running 5.0.45.

Thanks,
~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
On Oct 22, 2009, at 3:26 PM, Eddie Drapkin wrote:

On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson <philthath...@gmail.com > wrote:
Hi all.

I'm running into a random issue where sometimes it take several minutes (up to 10 or 15) to complete a query. According to 1 or 2 references, this may be a mysql bug. These links explain the similar problem I'm experiencing:

http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully queried (in milliseconds) approximately 50,000 times before it took several minutes to query, which hung all the other processes on the database. Because it
occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP? E.g., when I
call mysql_query() and it takes 30 seconds, then quit processing that
function and continue on. I know I could set_time_limit() to a specific time, but that would cause a fatal error... and I want to be able to catch
it.

Any thoughts on what direction I should go? Also, I'm going to do some
research to see if a newer version of mysql has fixed this bug. We're
running 5.0.45.

Thanks,
~Philip

You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.

I didn't think you could catch fatal errors - isn't that why they're fatal?

I will check into the query cache thing. However, the query that I'm running isn't exactly the same each time. Each iteration has a different ID value in the WHERE clause.

Thank you,
~Philip


--- End Message ---
--- Begin Message ---
On Oct 22, 2009, at 3:30 PM, Phpster wrote:

Have you run an explain plan on the query?

Bastien

Sent from my iPod

Yes, I have. For giggles, I wanted to run it again. Here it is (slightly stripped down) and it looks good to me.

mysql> EXPLAIN SELECT
    -> `p`.`patient_id`,
    -> `p`.`address_id`,
    -> `p`.`patient_sub_id`,
-> AES_DECRYPT(`p`.`patient_first_name`, 'hidden_key') AS `patient_first_name`, -> AES_DECRYPT(`p`.`patient_last_name`, 'hidden_key') AS `patient_last_name`, -> AES_DECRYPT(`p`.`patient_middle_name`, 'hidden_key') AS `patient_middle_name`,
    -> AES_DECRYPT(`p`.`patient_dob`, 'hidden_key') AS `patient_dob`
    -> FROM `patient` `p`
-> INNER JOIN `center_patient` `cp` ON `p`.`patient_id` = `cp`.`patient_id` -> WHERE ((`p`.`patient_id` = '256783' OR `p`.`patient_sub_id` = '256783') AND `cp`.`center_id` = '109')
    -> ORDER BY `patient_id` DESC;
+----+---------+--------------------+------ +------------------------------------------------------------------+ | id | key_len | ref | rows | Extra | +----+---------+--------------------+------ +------------------------------------------------------------------+ | 1 | 4,4 | NULL | 2 | Using union (PRIMARY,patient_sub_id); Using where; Using filesort | | 1 | 8 | p.patient_id,const | 1 | Using index | +----+---------+--------------------+------ +------------------------------------------------------------------+
2 rows in set (0.00 sec)

There are about 350,000 records in `patient` and `center_patient` tables. The average number of rows returned from this query is less than 5.

~Philip


On Oct 22, 2009, at 4:14 PM, Philip Thompson <philthath...@gmail.com> wrote:

Hi all.

I'm running into a random issue where sometimes it take several minutes (up to 10 or 15) to complete a query. According to 1 or 2 references, this may be a mysql bug. These links explain the similar problem I'm experiencing:

http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully queried (in milliseconds) approximately 50,000 times before it took several minutes to query, which hung all the other processes on the database. Because it occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP? E.g., when I call mysql_query() and it takes 30 seconds, then quit processing that function and continue on. I know I could set_time_limit() to a specific time, but that would cause a fatal error... and I want to be able to catch it.

Any thoughts on what direction I should go? Also, I'm going to do some research to see if a newer version of mysql has fixed this bug. We're running 5.0.45.

Thanks,
~Philip

--- End Message ---
--- Begin Message ---
I'm trying to use the php mail() function to send a mail within a php
script. This is using PHP 5.2.4 and Ubuntu Hardy Heron linux. The
script runs fine and the return value of the mail function is TRUE,
but the mail is never received. I'm trying to send an email to my
gmail account via the local server on my machine, just to test if this
script works.

I installed postfix because I read in several places that people have
had good luck with that mail program. From what I can tell, postfix is
working. I can do:

telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 homemade ESMTP Postfix (Ubuntu)
ehlo localhost
250-homemade
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

After the php script runs, I type 'mailq' and get the result 'mail
queue is empty.' If I check /var/log/mail.log, this is what I see:

Oct 21 23:54:35 homemade postfix/pickup[5735]: 2A31EA70109: uid=33
from=<www-data>
Oct 21 23:54:35 homemade postfix/cleanup[7997]: 2A31EA70109:
message-id=<20091022065435.2a31ea70...@homemade>
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109:
from=<www-d...@homemade>, size=499, nrcpt=1 (queue active)
Oct 21 23:54:35 homemade postfix/error[7999]: 2A31EA70109:
to=<x...@gmail.com>, relay=none, delay=0.04, delays=0.03/0/0/0.01,
dsn=5.0.0, status=bounced (gmail.com)
Oct 21 23:54:35 homemade postfix/cleanup[7997]: 3217DA7010A:
message-id=<20091022065435.3217da70...@homemade>
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: from=<>,
size=2095, nrcpt=1 (queue active)
Oct 21 23:54:35 homemade postfix/bounce[8000]: 2A31EA70109: sender
non-delivery notification: 3217DA7010A
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109: removed
Oct 21 23:54:35 homemade postfix/local[8001]: 3217DA7010A:
to=<www-d...@homemade>, relay=local, delay=0.03, delays=0/0.02/0/0.01,
dsn=2.0.0, status=sent (delivered to command: procmail -a
"$EXTENSION")
Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: removed

Any ideas? I am new both to php and postfix. Thanks for any help.

--- End Message ---
--- Begin Message ---
The problem is you won't be trusted to deliver mail directly to most
mail servers unless you have a static IP.  Even then thats no
guarantee.  What you have to do is relay through your ISP's SMTP
server where you're "trusted".  You should also be able to setup PHP
to use your ISP's SMTP server and never touch the SMTP service on your
local machine (if you don't feel like playing with Postfix).

On Thu, Oct 22, 2009 at 3:56 PM, James Prentice <prentice....@gmail.com> wrote:
> I'm trying to use the php mail() function to send a mail within a php
> script. This is using PHP 5.2.4 and Ubuntu Hardy Heron linux. The
> script runs fine and the return value of the mail function is TRUE,
> but the mail is never received. I'm trying to send an email to my
> gmail account via the local server on my machine, just to test if this
> script works.
>
> I installed postfix because I read in several places that people have
> had good luck with that mail program. From what I can tell, postfix is
> working. I can do:
>
> telnet localhost 25
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> 220 homemade ESMTP Postfix (Ubuntu)
> ehlo localhost
> 250-homemade
> 250-PIPELINING
> 250-SIZE 10240000
> 250-VRFY
> 250-ETRN
> 250-STARTTLS
> 250-ENHANCEDSTATUSCODES
> 250-8BITMIME
> 250 DSN
>
> After the php script runs, I type 'mailq' and get the result 'mail
> queue is empty.' If I check /var/log/mail.log, this is what I see:
>
> Oct 21 23:54:35 homemade postfix/pickup[5735]: 2A31EA70109: uid=33
> from=<www-data>
> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 2A31EA70109:
> message-id=<20091022065435.2a31ea70...@homemade>
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109:
> from=<www-d...@homemade>, size=499, nrcpt=1 (queue active)
> Oct 21 23:54:35 homemade postfix/error[7999]: 2A31EA70109:
> to=<x...@gmail.com>, relay=none, delay=0.04, delays=0.03/0/0/0.01,
> dsn=5.0.0, status=bounced (gmail.com)
> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 3217DA7010A:
> message-id=<20091022065435.3217da70...@homemade>
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: from=<>,
> size=2095, nrcpt=1 (queue active)
> Oct 21 23:54:35 homemade postfix/bounce[8000]: 2A31EA70109: sender
> non-delivery notification: 3217DA7010A
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109: removed
> Oct 21 23:54:35 homemade postfix/local[8001]: 3217DA7010A:
> to=<www-d...@homemade>, relay=local, delay=0.03, delays=0/0.02/0/0.01,
> dsn=2.0.0, status=sent (delivered to command: procmail -a
> "$EXTENSION")
> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: removed
>
> Any ideas? I am new both to php and postfix. Thanks for any help.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
How would I determine my ISP's SMPT server ID? And do I need to edit
main.cf in order to use that server?

Also, is there a way to test the script just sending an email locally?
I tried sending the email to use...@localhost, but the email was still
not received.



On Thu, Oct 22, 2009 at 4:15 PM, LinuxManMikeC <linuxmanmi...@gmail.com> wrote:
> The problem is you won't be trusted to deliver mail directly to most
> mail servers unless you have a static IP.  Even then thats no
> guarantee.  What you have to do is relay through your ISP's SMTP
> server where you're "trusted".  You should also be able to setup PHP
> to use your ISP's SMTP server and never touch the SMTP service on your
> local machine (if you don't feel like playing with Postfix).
>
> On Thu, Oct 22, 2009 at 3:56 PM, James Prentice <prentice....@gmail.com> 
> wrote:
>> I'm trying to use the php mail() function to send a mail within a php
>> script. This is using PHP 5.2.4 and Ubuntu Hardy Heron linux. The
>> script runs fine and the return value of the mail function is TRUE,
>> but the mail is never received. I'm trying to send an email to my
>> gmail account via the local server on my machine, just to test if this
>> script works.
>>
>> I installed postfix because I read in several places that people have
>> had good luck with that mail program. From what I can tell, postfix is
>> working. I can do:
>>
>> telnet localhost 25
>> Trying 127.0.0.1...
>> Connected to localhost.
>> Escape character is '^]'.
>> 220 homemade ESMTP Postfix (Ubuntu)
>> ehlo localhost
>> 250-homemade
>> 250-PIPELINING
>> 250-SIZE 10240000
>> 250-VRFY
>> 250-ETRN
>> 250-STARTTLS
>> 250-ENHANCEDSTATUSCODES
>> 250-8BITMIME
>> 250 DSN
>>
>> After the php script runs, I type 'mailq' and get the result 'mail
>> queue is empty.' If I check /var/log/mail.log, this is what I see:
>>
>> Oct 21 23:54:35 homemade postfix/pickup[5735]: 2A31EA70109: uid=33
>> from=<www-data>
>> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 2A31EA70109:
>> message-id=<20091022065435.2a31ea70...@homemade>
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109:
>> from=<www-d...@homemade>, size=499, nrcpt=1 (queue active)
>> Oct 21 23:54:35 homemade postfix/error[7999]: 2A31EA70109:
>> to=<x...@gmail.com>, relay=none, delay=0.04, delays=0.03/0/0/0.01,
>> dsn=5.0.0, status=bounced (gmail.com)
>> Oct 21 23:54:35 homemade postfix/cleanup[7997]: 3217DA7010A:
>> message-id=<20091022065435.3217da70...@homemade>
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: from=<>,
>> size=2095, nrcpt=1 (queue active)
>> Oct 21 23:54:35 homemade postfix/bounce[8000]: 2A31EA70109: sender
>> non-delivery notification: 3217DA7010A
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 2A31EA70109: removed
>> Oct 21 23:54:35 homemade postfix/local[8001]: 3217DA7010A:
>> to=<www-d...@homemade>, relay=local, delay=0.03, delays=0/0.02/0/0.01,
>> dsn=2.0.0, status=sent (delivered to command: procmail -a
>> "$EXTENSION")
>> Oct 21 23:54:35 homemade postfix/qmgr[5736]: 3217DA7010A: removed
>>
>> Any ideas? I am new both to php and postfix. Thanks for any help.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

--- End Message ---
--- Begin Message ---
On Thu, Oct 22, 2009 at 06:24:14PM -0700, James Prentice wrote:

> How would I determine my ISP's SMPT server ID? And do I need to edit
> main.cf in order to use that server?

What ID? There's no ID needed. You just configure postfix to relay any
non-local mail sent to it to the SMTP server at your ISP. Check the
headers in incoming mail sent to you for the name of that server. It's
likely the same for both incoming and outgoing mail. Something like
mail.myisp.com.

One other note. People look at me like I'm crazy when I mention this,
but I've seen it quite a bit at various internet mail servers.
Sometimes, in order to accept email from you, the internet mail server
must see you *receive* mail within a certain time period prior. That is,
you have to go fetch your mail at the ISP, which opens a "window" into
the SMTP server for a limited time. Then you can tender mail to the
internet mail server. I don't know that your internet mail server
operates this way, but it's something to consider. I've had to deal with
this before myself.

Configuring local SMTP servers, like postfix. Check and see if Ubuntu
has some sort of setup utility for this. Or try

dpkg-reconfigure postfix

Setting up mail servers is tedious and error prone, unless you've done
it a lot. Read The Fine Manual on postfix.

> 
> Also, is there a way to test the script just sending an email locally?
> I tried sending the email to use...@localhost, but the email was still
> not received.
> 

It will work, assuming three things:

1. You have an actual user set up on the system to receive mail. That
is, an actual user on the system, with an entry in the passwd file and a
home directory, etc.

2. Postfix is configured to deliver truly local mail to local addresses.
More postfix configuration fun.

3. Postfix is actually running and properly configured. If not
configured properly, it may refuse to run.

In any case, linuxmanmikec's comment about the internet mail server not
trusting you on a dynamic IP is spot on. The web of email trust is such
that internet mail servers only trust other internet mail servers. And
*your* internet mail server will trust *you*. So to get mail to that
other internet mail server over there, you'll have to give it to *your*
internet mail server, which is the only one that internet mail server
over there will trust. The "bounce" message you got indicates that
relaying from you is forbidden at the destination mail server.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Paul M Foster wrote:
> On Thu, Oct 22, 2009 at 06:24:14PM -0700, James Prentice wrote:
> 
> One other note. People look at me like I'm crazy when I mention this,
> but I've seen it quite a bit at various internet mail servers.
> Sometimes, in order to accept email from you, the internet mail server
> must see you *receive* mail within a certain time period prior. That is,
> you have to go fetch your mail at the ISP, which opens a "window" into
> the SMTP server for a limited time. Then you can tender mail to the
> internet mail server. I don't know that your internet mail server
> operates this way, but it's something to consider. I've had to deal with
> this before myself.

This is commonly known as POP lock and is one of the two main ways that
a mail server allows you to relay a message.  If you have authenticated
via POP3 (i.e. checked your mail) in a certain period of time then the
SMTP server will let you send.  The other main one is by authentication
(username/password) with the SMTP server when you attempt to send mail.

> In any case, linuxmanmikec's comment about the internet mail server not
> trusting you on a dynamic IP is spot on. The web of email trust is such
> that internet mail servers only trust other internet mail servers. And
> *your* internet mail server will trust *you*. So to get mail to that
> other internet mail server over there, you'll have to give it to *your*
> internet mail server, which is the only one that internet mail server
> over there will trust. The "bounce" message you got indicates that
> relaying from you is forbidden at the destination mail server.
> 

This is fairly accurate in premise but just to clarify.  Mailservers
don't operate like this by default and there is really no "trust".
There are public blacklists that a mailserver can be configured to use
that tell the mailserver not to accept mail from servers on the
blacklist.  The blacklists may contain servers that allow anyone to
relay email, compromised servers, servers known for spam, ip ranges
known to be held by spammers and *ranges that ISPs designate as dynamic
or used for subscribers (DSL, cable, dial-up customers, etc. because
they shouldn't be relaying email).

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On Thu, Oct 22, 2009 at 11:40:34PM -0500, Shawn McKenzie wrote:

<snip>

> This is fairly accurate in premise but just to clarify.  Mailservers
> don't operate like this by default and there is really no "trust".
> There are public blacklists that a mailserver can be configured to use
> that tell the mailserver not to accept mail from servers on the
> blacklist.  The blacklists may contain servers that allow anyone to
> relay email, compromised servers, servers known for spam, ip ranges
> known to be held by spammers and *ranges that ISPs designate as dynamic
> or used for subscribers (DSL, cable, dial-up customers, etc. because
> they shouldn't be relaying email).

Regarding the rejection of dynamic IPs by smarthosts, are you saying
that it's a "blacklist" of sorts that lets them know an IP is dynamic?
(Serious question. I don't know the mechanism by which they determine
what is and isn't a dynamic IP.)

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
i faced the same problem quite a few times.

the general email route is
php script -> sender smtp server -> receiving mail server
in your case path 2 is broken. meaning port 25 is blocked by your ISP

the work around is:
1. see if your ISP provides you with an SMTP account that is not blocked (OR)
2. try using a socks

--- End Message ---
--- Begin Message ---
I have several input fields to update a book database. There seems to be
a conflict in the way tags and text are input through php/mysql and
phpMyAdmin. If I enter the data with phpMyAdmin the input fields in the
php page see quotation marks differently than what is input in phpMyAdmin.
example:
if the data is input through the update form, single quotes cause an
error. Double quotes update the db but when the edit(update) form
displays the text for modification outside the input field except for
the first part, precisely where the first quotation mark appears in the
text - as below:

*<b>Reviewed by <a href=*"mailto:recipi...@somewhere.com";>Recipient:
blah, blah, blah...religion." _size="50" />_
The text in square brackets is displayed outside the input field and
includes part of the code at the end.
bold is within the field, the rest is outside and the underlined is part
of code.

If the same text is entered with phpMyAdmin using single quotes and the
&quot; characters, the display in the editing field shows correctly...
but it will not update, that is, the update query generates errors and
only accepts the double quotes within the tags.

So, the question is, are there some kind of metacharacters to be used to
have mysql accept the " ? I have triee backslashing, forward slashing
and they don't do it.

Or is there an encoding conflict here? It looks like a display and save
mismatch somewhere...

below is another example:
<a
href='http://www.amazon.com/exec/obidos/ASIN/0773468943/frankiesbibliogo'><IMG
height=68 alt="Order This Book From Amazon.com"
src="../images/amazon1.gif" width=90 border=0 /></a>

The single quotes for the href seem to work. But the " does not work;
and using &quot; or &rsquo;  also also do not display correctly; again,
from "Order... the image is not displayed but only the image blank with
"Order.. " in it.
I'm rather puzzled.








--- End Message ---
--- Begin Message ---
Hi,

I am working on reverse engineering for a web project. I was trying to know
that, is there any way(function by PHP, Zend, extension etc)
to find out how many function has been called to perform a task.

If no, can you suggest is it possible/feasible or not?


Thanks in advance
-- 
Satya
Bangalore.

--- End Message ---

Reply via email to