pop3 over sockets

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Georg Gerber

    pop3 over sockets

    Hello,

    on a php page I want to display the content of a POP3 mailbox and to show
    the following informations:

    current number, content-length, sender, subject

    I use the following code:


    // open the socket
    $socketPOP = fsockopen($pop, 110);
    fgets($socketPO P);
    fputs($socketPO P, "USER myName\n");
    fgets($socketPO P);
    fputs($socketPO P, "PASS myPassword\n");
    fgets($socketPO P);

    // load list
    fputs($socketPO P, "LIST\n");



    Now I read the lines with
    $zeile = fgets($socketPO P);
    and get from it the current numbers and the content lengths.


    Then I send for every mail:

    fputs($socketPO P, "RETR $currentNumber\ n");

    and parse the returnd lines for the strings "From:" and "Subject:".

    My problem is, that the whole mail is sended and I have to read ALL data
    from the socket, before I can get the data from the next mail. If I have
    lots of large mails, I create with this code very much traffic.
    How can I avoid this unnecessary traffic?

    Georg Gerber

  • Pedro Graca

    #2
    Re: [OT] pop3 over sockets

    Georg Gerber wrote:[color=blue]
    > Then I send for every mail:
    >
    > fputs($socketPO P, "RETR $currentNumber\ n");
    >
    > and parse the returnd lines for the strings "From:" and "Subject:".
    >
    > My problem is, that the whole mail is sended and I have to read ALL data
    > from the socket, before I can get the data from the next mail. If I have
    > lots of large mails, I create with this code very much traffic.
    > How can I avoid this unnecessary traffic?[/color]

    You might want to review the POP3 protocol


    and use TOP instead of RETR
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Manuel Lemos

      #3
      Re: pop3 over sockets

      Hello,

      On 02/20/2004 09:51 AM, Georg Gerber wrote:[color=blue]
      > on a php page I want to display the content of a POP3 mailbox and to show
      > the following informations:
      >
      > current number, content-length, sender, subject[/color]

      You may want to try this POP3 client class:



      --

      Regards,
      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP


      PHP Reviews - Reviews of PHP books and other products


      Metastorage - Data object relational mapping layer generator

      Comment

      Working...