Loading ...
Sorry, an error occurred while loading the content.
 

Re: [php4india] {Query} How to retrieve the new messages from IMAP

Expand Messages
  • Sreeni .A
    hi rajesh... This is late reply offcourse ,,.. Thought might be helpful if you are still facing problem.... here is a code in illoha mail opensource
    Message 1 of 4 , Dec 2, 2006
      hi rajesh...

        This is late reply offcourse ,,..

        Thought might be helpful if you are still facing problem....


         here is a code in illoha mail opensource
               $conn=iil_Connect($host, $user, $password, "plain");
          $fp = $conn->fp;
          if ($fp){
              fputs($fp, "a002 EXAMINE \"$mailbox\"\r\n");
              do{
                  $line=chop(iil_ReadLine($fp, 300));
                  $a=explode(" ", $line);
                  if (($a[0]=="*") && (strcasecmp($a[2], "RECENT")==0))  $result=(int)$a[1];
              }while (!iil_StartsWith($a[0],"a002"));

              fputs($fp, "a003 LOGOUT\r\n");
              fclose($fp);
          }else $result=-2;
      ---

       Generally in linux we have to connect the mail server using telnet we can the for recent message
          ]$    telnet 10.10.10.2 143
        
      here 143 is the port used by IMAP
      this command is used to connect the mail server which is 10.10.10.2 (this is our local mal server)

      now login tothe server

         ]$   a001 login sreenivasulu@... password
      it will respons as follow
                 a001 OK LOGIN Ok.

       now to check the recent message
         ]$  a002 EXAMINE INBOX

      now it will output as
          * FLAGS ($MDNSent \Draft \Answered \Flagged \Deleted \Seen \Recent)
          * OK [PERMANENTFLAGS ()] No permanent flags permitted
          * 266 EXISTS
          * 1 RECENT
          * OK [UIDVALIDITY 1147065309] Ok
          * OK [MYRIGHTS "acdilrsw"] ACL
          a002 OK [READ-ONLY] Ok

      where the the digi '1' on line 4 is the count of new messages since last read.

      In the above logic he is doing all this....
      now will get the message by id the number of message in that mail box "INBOX"

      --
      Let me check the available function in PHP

      - Sreeni.A



      On 11/17/06, muthu_rajesh81 <muthu_rajesh81@...> wrote:

      Hi Friends,

      i am able to do fetch mails from imap server and listed in the mail box.

      Now my need is, i want to retrieve the newly arrived message and
      insert that as a first row in my mails list using ajax.
      i can add the resulted messages in the list. But i couldn't get the
      new messages only.
      when i tried the PHP function imap_search it gives the list of all
      mails (which are all mails available in the IMAP server ie., seen,
      deleted, etc)
      i tried to pass NEW in this function
      ie., imap_search($MailBox->mbox, "NEW");
      but it returns all the mails instead of newly arrived mails.

      Also i have searched in google and somewhere i found that this
      imap_search function is supported only for IMAP2 and not supported in
      IMAP4. Isn't it?

      anybody know how to get the new messages using imap_search or some
      other function?

      Thanks
      Rajeshkannan


    • Rajeshkannan
      Hi Sreeni, Thanks for your help. But iil_Connect is the illoha mail function not a PHP function. am i right? if i am wrong then let me know. i have looked for
      Message 2 of 4 , Dec 5, 2006
        Hi Sreeni,

        Thanks for your help.
        But iil_Connect is the illoha mail function not a PHP function. am i
        right? if i am wrong then let me know.

        i have looked for the solution but didn't succeed.

        Anyway i have done this ie., added the new mails in the Inbox list.
        what i have done is, get all messages, loop through all messages, and
        will add the mail in the Inbox if it is not alrady available in the
        Inbox. suppose if it is already available in the Inbox then i will not
        add.

        I know this is a workaround not a solution. Also when the number of
        mails are less in count then it is ok, but when the mail count
        increases to lakhs then the performance will be down.

        In the mean time if you found any solution then let me know.

        With Regards
        Rajeshkannan


        --- In php4india@yahoogroups.com, "Sreeni .A" <sreeniaphpcoder@...> wrote:
        >
        > hi rajesh...
        >
        > This is late reply offcourse ,,..
        >
        > Thought might be helpful if you are still facing problem....
        >
        >
        > here is a code in illoha mail opensource
        > $conn=iil_Connect($host, $user, $password, "plain");
        > $fp = $conn->fp;
        > if ($fp){
        > fputs($fp, "a002 EXAMINE \"$mailbox\"\r\n");
        > do{
        > $line=chop(iil_ReadLine($fp, 300));
        > $a=explode(" ", $line);
        > if (($a[0]=="*") && (strcasecmp($a[2], "RECENT")==0))
        > $result=(int)$a[1];
        > }while (!iil_StartsWith($a[0],"a002"));
        >
        > fputs($fp, "a003 LOGOUT\r\n");
        > fclose($fp);
        > }else $result=-2;
        > ---
        >
        > Generally in linux we have to connect the mail server using telnet
        we can
        > the for recent message
        > ]$ telnet 10.10.10.2 143
        >
        > here 143 is the port used by IMAP
        > this command is used to connect the mail server which is 10.10.10.2
        (this is
        > our local mal server)
        >
        > now login tothe server
        >
        > ]$ a001 login sreenivasulu@... password
        > it will respons as follow
        > a001 OK LOGIN Ok.
        >
        > now to check the recent message
        > ]$ a002 EXAMINE INBOX
        >
        > now it will output as
        > * FLAGS ($MDNSent \Draft \Answered \Flagged \Deleted \Seen \Recent)
        > * OK [PERMANENTFLAGS ()] No permanent flags permitted
        > * 266 EXISTS
        > * 1 RECENT
        > * OK [UIDVALIDITY 1147065309] Ok
        > * OK [MYRIGHTS "acdilrsw"] ACL
        > a002 OK [READ-ONLY] Ok
        >
        > where the the digi '1' on line 4 is the count of new messages since last
        > read.
        >
        > In the above logic he is doing all this....
        > now will get the message by id the number of message in that mail box
        > "INBOX"
        >
        > --
        > Let me check the available function in PHP
        >
        > - Sreeni.A
        >
        >
        >
        > On 11/17/06, muthu_rajesh81 <muthu_rajesh81@...> wrote:
        > >
        > > Hi Friends,
        > >
        > > i am able to do fetch mails from imap server and listed in the
        mail box.
        > >
        > > Now my need is, i want to retrieve the newly arrived message and
        > > insert that as a first row in my mails list using ajax.
        > > i can add the resulted messages in the list. But i couldn't get the
        > > new messages only.
        > > when i tried the PHP function imap_search it gives the list of all
        > > mails (which are all mails available in the IMAP server ie., seen,
        > > deleted, etc)
        > > i tried to pass NEW in this function
        > > ie., imap_search($MailBox->mbox, "NEW");
        > > but it returns all the mails instead of newly arrived mails.
        > >
        > > Also i have searched in google and somewhere i found that this
        > > imap_search function is supported only for IMAP2 and not supported in
        > > IMAP4. Isn't it?
        > >
        > > anybody know how to get the new messages using imap_search or some
        > > other function?
        > >
        > > Thanks
        > > Rajeshkannan
        > >
        > >
        > >
        >
      • Sreeni .A
        Hi rajesh.. I can suggest you to go with some open sources The popular one is squirrelmail and another is ilohamail .. and ajaxbased one, which i am working
        Message 3 of 4 , Dec 7, 2006
          Hi rajesh..

           I can suggest you to go with some open sources

           The popular one is squirrelmail
           
             and another is ilohamail ..
             and ajaxbased one, which i am working present is 'RoundCube mail'...

           If you know any other please let me know

          Thanking you
          -Sreeni.A

           
           


          On 12/6/06, Rajeshkannan < muthu_rajesh81@...> wrote:

          Hi Sreeni,

          Thanks for your help.
          But iil_Connect is the illoha mail function not a PHP function. am i
          right? if i am wrong then let me know.

          i have looked for the solution but didn't succeed.

          Anyway i have done this ie., added the new mails in the Inbox list.
          what i have done is, get all messages, loop through all messages, and
          will add the mail in the Inbox if it is not alrady available in the
          Inbox. suppose if it is already available in the Inbox then i will not
          add.

          I know this is a workaround not a solution. Also when the number of
          mails are less in count then it is ok, but when the mail count
          increases to lakhs then the performance will be down.

          In the mean time if you found any solution then let me know.

          With Regards
          Rajeshkannan



          --- In php4india@yahoogroups.com, "Sreeni .A" <sreeniaphpcoder@...> wrote:
          >
          > hi rajesh...
          >
          > This is late reply offcourse ,,..
          >
          > Thought might be helpful if you are still facing problem....
          >
          >
          > here is a code in illoha mail opensource
          > $conn=iil_Connect($host, $user, $password, "plain");
          > $fp = $conn->fp;
          > if ($fp){
          > fputs($fp, "a002 EXAMINE \"$mailbox\"\r\n");
          > do{
          > $line=chop(iil_ReadLine($fp, 300));
          > $a=explode(" ", $line);
          > if (($a[0]=="*") && (strcasecmp($a[2], "RECENT")==0))
          > $result=(int)$a[1];
          > }while (!iil_StartsWith($a[0],"a002"));
          >
          > fputs($fp, "a003 LOGOUT\r\n");
          > fclose($fp);
          > }else $result=-2;
          > ---
          >
          > Generally in linux we have to connect the mail server using telnet
          we can
          > the for recent message
          > ]$ telnet 10.10.10.2 143
          >
          > here 143 is the port used by IMAP
          > this command is used to connect the mail server which is 10.10.10.2
          (this is
          > our local mal server)
          >
          > now login tothe server
          >
          > ]$ a001 login sreenivasulu@... password
          > it will respons as follow
          > a001 OK LOGIN Ok.
          >
          > now to check the recent message
          > ]$ a002 EXAMINE INBOX
          >
          > now it will output as
          > * FLAGS ($MDNSent \Draft \Answered \Flagged \Deleted \Seen \Recent)
          > * OK [PERMANENTFLAGS ()] No permanent flags permitted
          > * 266 EXISTS
          > * 1 RECENT
          > * OK [UIDVALIDITY 1147065309] Ok
          > * OK [MYRIGHTS "acdilrsw"] ACL
          > a002 OK [READ-ONLY] Ok
          >
          > where the the digi '1' on line 4 is the count of new messages since last
          > read.
          >
          > In the above logic he is doing all this....
          > now will get the message by id the number of message in that mail box
          > "INBOX"
          >
          > --
          > Let me check the available function in PHP
          >
          > - Sreeni.A
          >
          >
          >
          > On 11/17/06, muthu_rajesh81 <muthu_rajesh81@...> wrote:
          > >
          > > Hi Friends,
          > >
          > > i am able to do fetch mails from imap server and listed in the
          mail box.
          > >
          > > Now my need is, i want to retrieve the newly arrived message and
          > > insert that as a first row in my mails list using ajax.
          > > i can add the resulted messages in the list. But i couldn't get the
          > > new messages only.
          > > when i tried the PHP function imap_search it gives the list of all
          > > mails (which are all mails available in the IMAP server ie., seen,
          > > deleted, etc)
          > > i tried to pass NEW in this function
          > > ie., imap_search($MailBox->mbox, "NEW");
          > > but it returns all the mails instead of newly arrived mails.
          > >
          > > Also i have searched in google and somewhere i found that this
          > > imap_search function is supported only for IMAP2 and not supported in
          > > IMAP4. Isn't it?
          > >
          > > anybody know how to get the new messages using imap_search or some
          > > other function?
          > >
          > > Thanks
          > > Rajeshkannan
          > >
          > >
          > >
          >


        Your message has been successfully submitted and would be delivered to recipients shortly.