Re: [PHP] imap_search ?
Imap remains open after you search and doesn't close until you call imap_close. Firstly the code shouldn't be written like that, while should not operate on a fail condition of a function exec, that's just bad coding practice and that's what causes a loop here. If there are no messages in the email box, imap search will return false, and you will have a loop until it gets a message... Here is what your scrip does: First run: Get all messages Gets array of messages Fails while condition Fetch Print Delete all Exit Next time: Get messages Gets false (no messages) Hits while loop where by it will continue to send imap requests until a message hits the mail box (your almost infinite loop) . -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Tontonq Tontonq wrote: hi ! it works if there is / are emails in the box before script run (i use cli not web based) but after it works 1 time it doesnt work again it enters to infinite loop , at that line while(!$emails) { $emails = imap_search($inbox,'ALL'); echo "email yok\n"; print_r($emails); } imap_search($inbox,'ALL'); it doesn't try to research emails in $inbox, doesn't it stay as connected or it's just for 1 time use :S ? should i reuse imap_open everytime when i need to use imap_search ? $inbox = imap_open($hostname,$usernamex,$password) or die('Cannot connect to domain:' . imap_last_error()); function onayla() { global $inbox; $emails = imap_search($inbox,'ALL'); while(!$emails) { $emails = imap_search($inbox,'ALL'); echo "email yok\n"; print_r($emails); } echo "\nyeaah"; print_r($emails); if($emails) { rsort($emails); echo "Number of email:".imap_num_msg($inbox); foreach($emails as $email_number) { $overview = imap_fetch_overview($inbox,$email_number,0); if(stristr($overview[0]->subject,"Test")) { $message = imap_fetchbody($inbox,$email_number,1); echo "$message\n\r"; //$link=arasi('activate:','-- The',$message); //echo "\n\r".$link; #fwrite(fopen("deneme.txt",w),file_get_contents($link)); //imap_delete($inbox,'1:*'); //imap_expunge($inbox); } } } imap_delete($inbox,'1:*'); imap_expunge($inbox); }
[PHP] imap_search ?
hi ! it works if there is / are emails in the box before script run (i use cli not web based) but after it works 1 time it doesnt work again it enters to infinite loop , at that line while(!$emails) { $emails = imap_search($inbox,'ALL'); echo "email yok\n"; print_r($emails); } imap_search($inbox,'ALL'); it doesn't try to research emails in $inbox, doesn't it stay as connected or it's just for 1 time use :S ? should i reuse imap_open everytime when i need to use imap_search ? $inbox = imap_open($hostname,$usernamex,$password) or die('Cannot connect to domain:' . imap_last_error()); function onayla() { global $inbox; $emails = imap_search($inbox,'ALL'); while(!$emails) { $emails = imap_search($inbox,'ALL'); echo "email yok\n"; print_r($emails); } echo "\nyeaah"; print_r($emails); if($emails) { rsort($emails); echo "Number of email:".imap_num_msg($inbox); foreach($emails as $email_number) { $overview = imap_fetch_overview($inbox,$email_number,0); if(stristr($overview[0]->subject,"Test")) { $message = imap_fetchbody($inbox,$email_number,1); echo "$message\n\r"; //$link=arasi('activate:','-- The',$message); //echo "\n\r".$link; #fwrite(fopen("deneme.txt",w),file_get_contents($link)); //imap_delete($inbox,'1:*'); //imap_expunge($inbox); } } } imap_delete($inbox,'1:*'); imap_expunge($inbox); }
Re: [PHP] php imap_search fails for subject strings which have apostrophe
Thanks for the reply. I had posted this on gmail forums and someone just posted this is a server-side limitation actually. http://www.google.com/support/forum/p/gmail/thread?fid=05fef86a09eb199d00049338b3282f61&hl=en I guess I'll have to figure out other ways ways to make this happen On Sat, Oct 23, 2010 at 4:16 AM, Govinda wrote: > I've to search for messages from Gmail Inbox over IMAP using search by >> SUBJECT . The php-imap imap_search() works fine when the subject is pure >> alphanumeric. If the subject string has an apostrophe or a dash then the >> search fails. >> >> imap_seach($mbox, 'ALL SUBJECT ""'); >> >> imap_seach($mbox, 'ALL SUBJECT "this is a string without quote"'); //Works >> imap_seach($mbox, 'ALL SUBJECT "this is a string with quote's and >> da-sh"'); >> //Doesn't Work >> >> I've tried using the Zend Framework IMAP library too, it fails too. I've >> been talking to people over some forums, they say subject search via imap >> on >> gmail works for them. >> >> What can be the problem here? I've tried escaping them but it did not >> help. >> >> Any help is appreciated. >> >> -- >> Regards, >> >> Nitesh Nandy >> > > > Hi Nitesh, > > I am a newbie in PHP, but I would guess the way you are attempting to > escape the non-alphanumeric chars is faulty. > Can you please show the code you are using to do the escaping? > > > Govinda > > -- Regards, Nitesh Nandy
Re: [PHP] php imap_search fails for subject strings which have apostrophe
I've to search for messages from Gmail Inbox over IMAP using search by SUBJECT . The php-imap imap_search() works fine when the subject is pure alphanumeric. If the subject string has an apostrophe or a dash then the search fails. imap_seach($mbox, 'ALL SUBJECT ""'); imap_seach($mbox, 'ALL SUBJECT "this is a string without quote"'); // Works imap_seach($mbox, 'ALL SUBJECT "this is a string with quote's and da- sh"'); //Doesn't Work I've tried using the Zend Framework IMAP library too, it fails too. I've been talking to people over some forums, they say subject search via imap on gmail works for them. What can be the problem here? I've tried escaping them but it did not help. Any help is appreciated. -- Regards, Nitesh Nandy Hi Nitesh, I am a newbie in PHP, but I would guess the way you are attempting to escape the non-alphanumeric chars is faulty. Can you please show the code you are using to do the escaping? Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php imap_search fails for subject strings which have apostrophe
I've to search for messages from Gmail Inbox over IMAP using search by SUBJECT . The php-imap imap_search() works fine when the subject is pure alphanumeric. If the subject string has an apostrophe or a dash then the search fails. imap_seach($mbox, 'ALL SUBJECT ""'); imap_seach($mbox, 'ALL SUBJECT "this is a string without quote"'); //Works imap_seach($mbox, 'ALL SUBJECT "this is a string with quote's and da-sh"'); //Doesn't Work I've tried using the Zend Framework IMAP library too, it fails too. I've been talking to people over some forums, they say subject search via imap on gmail works for them. What can be the problem here? I've tried escaping them but it did not help. Any help is appreciated. -- Regards, Nitesh Nandy
Re: [PHP] imap_search - criterion "ON"
2007. 11. 22, csütörtök keltezéssel 21.15-kor Max Frigge ezt írta: > Hey there, > > i am trying to use the imap_search function oh PHP. > In the documentation it says i can use ON to search for > a date. Whenever i try that I get: > > "Unknown search criterion: ON" > > Which is wired because ON is even mentioned in > the IMAP2 criteria?!? yep, ON is correct according to rfc3501 (IMAPv4rev1) > > Any ideas what's wrong? the problem is probably with the imap server. maybe it is not rfc compliant or something. greets Zoltán Németh > > Greets, Max > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imap_search - criterion "ON"
Hey there, i am trying to use the imap_search function oh PHP. In the documentation it says i can use ON to search for a date. Whenever i try that I get: "Unknown search criterion: ON" Which is wired because ON is even mentioned in the IMAP2 criteria?!? Any ideas what's wrong? Greets, Max -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imap_search and multiple criteria
Does the imap_search support multiple criteria? I've got the following successfully returning the correct results: However, when you try and put them in the same search e.g. $search = "BODY \"test\" OR SUBJECT \"test\"" It fails... The only way in which I can see this can be done is by joining the various arrays that are returned. Is this best? Thanks Nunners
Re: [PHP] Re:[PHP] imap_search and results
On Thu, 2004-08-26 at 09:25, fongming wrote: > for($i=0;$i { > [EMAIL PROTECTED]($mbox,$mails[$x-1]); > echo $subject=$h->subject; > echo $sender=$h->from[0]; > echo ""; > } Calling count() every time the for loop iterates is inefficient. $count = count($mails); for($i=0; $i<$count; $i++){ } -- Greg Donald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] imap_search and results
On Thu, 26 Aug 2004 22:25:00 +0800, fongming <[EMAIL PROTECTED]> wrote: > Hello: > >Here is my code : > >/---/ > >$mails = imap_search($mbox, 'TO "gentoo-user->[EMAIL PROTECTED]"',SE_UID); > >echo sizeof($mails); > >/--/ > > You can start to parse the mailheader,mailbody... > > for($i=0;$i { > [EMAIL PROTECTED]($mbox,$mails[$x-1]); > echo $subject=$h->subject; > echo $sender=$h->from[0]; > echo ""; > } > > Hi, nice to meet you! > -- > ¡»From: [EMAIL PROTECTED] > http://fonn.fongming.idv.tw > [EMAIL PROTECTED] > Thank you, I have finally found what is the thing which was the problem, it was the option SE_UID in the search function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re:[PHP] imap_search and results
Hello: >Here is my code : >/---/ >$mails = imap_search($mbox, 'TO "gentoo-user->[EMAIL PROTECTED]"',SE_UID); >echo sizeof($mails); >/--/ You can start to parse the mailheader,mailbody... for($i=0;$isubject; echo $sender=$h->from[0]; echo ""; } Hi, nice to meet you! -- ¡»From: [EMAIL PROTECTED] http://fonn.fongming.idv.tw [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imap_search and results
Hello, I'm trying to make a small script to show mails on a imap server with a criteria. Here is my code : /---/ $mails = imap_search($mbox, 'TO "[EMAIL PROTECTED]"',SE_UID); echo sizeof($mails); /--/ The connection to the server is the working, the search also, the size returned is not equal to 0. But now I don't know how to retrieve the number of the messages in the array. How can I do that ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imap_search question
hi. in the php manual the entry for imap_search states it has 3 arguments "imap_search ( resource imap_stream, string criteria, int options)" i get the first 2, but whats the third. at the end of the page it says "Valid values for flags are SE_UID, which causes the returned array to contain UIDs instead of messages sequence numbers. " so should imap_search ( $myStream, "ALL", SE_UID); return an array of the UIDs of the emails? because this is what i want. i need to work with the UIDs not the mesage numbers cheers folks Greg Brant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imap_search
$search = imap_search ($mail, "TO reply", SE_UID); returns the same values as $search = imap_search ($mail, "TO reply"); search whorks ok, but it doesnt return message id's. or this is imap-only flag and it won't work with pop3 connection? -- Andrew Perevodchik [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] imap_search?
Hello I'm trying to use imap_search to retrieve the all the post after a given date and then put them into a mysql DB. I don't know if this is the best way to do it. $searchstr = "SINCE Thu, 30 Aug 2001 12:05:49 +0200"; $search = imap_search($nntp, $searchstr, SE_UID); This should give me a array of all the post after the date in $searchstr, but instead it gives me all the posts in the newsgroup. Is there anyone that can help me? Thank you Shimon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]