fetching subject line from POP-mail using PHP

Discussion in 'Web Design & Coding' started by Glaanieboy, Aug 17, 2003.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    This is part of the code I use to check my mail:
    Code:
    for ($X=1;$X<=$num_messages;$X++){
    
     $header = imap_headerinfo($mbox,$X);
     $subject = $header->fetchsubject;
     $message = imap_body($mbox,$X);
     
    print "Message number $X:<BR>
     Subject: <B>$subject</B><BR>";
     $message = htmlspecialchars($message);
     print str_replace("\n", "<br>", $message)."<BR>************************************<BR>";
    }
    
    I've got one problem: PHP doesn't fetch the subject line for some reason. The problem must be in $subject = $header->fetchsubject, but all of the examples on PHP.net I've seen, use this piece of code. I tried $header->subject, $header['fetchsubject'], but nothing there. I know that there is a subject line in the message(s), because there is one in the test message I sent. Please help me.
     
  2. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I reread the additional messages on PHP.net and I found that imap_headerinfo($mbox,$X,80,80) was the trick.
     
  3. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    I am having trouble with my mail script cause of this problem ! the newest PHP i have works just a bit different.
     
  4. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    You mean php5?
     
  5. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    I think he has 4.3.2 RC4 as well
     
  6. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    He was referring to the 'newest' version. I guessed he meant 5.

    (does it matter? NOT!)
     
  7. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    nah 5 is still pretty much beta, if I didnt use allhope for beta testing code and so on I would give it a try but I dont wanna
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    i meant php5, i just backgraded.
     
  9. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    Ah oh well I cant be right all the time and its not like I could get on your server and check :p