PHP IMAP messege_id blank

Discussion in 'PHP' started by computerzworld, Jun 24, 2009.

  1. #1
    Hello,
    I am fetching mails from gmail and imap_fetch_overview function returns array of message information along with message_id that is only the unique thing to identify message identity. But for some mails it is blank. So how can I preserve unique identity of the messages as I am storing them in database. Please help me. Thanks in advance.
     
    computerzworld, Jun 24, 2009 IP
  2. adfly

    adfly Active Member

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Would a column in your database with an AUTO_INCREMENT ie. a primary key not be enough?

    Maybe you could create a column to store the MD5 of the time/subject of each message.
     
    adfly, Jun 24, 2009 IP
  3. computerzworld

    computerzworld Active Member

    Messages:
    214
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks for your reply. actually what i am doing over here is that i am storing particular mails into database and i want to preserve the identity of each mail as i will be comparing them in the database whether they are stored already or not. And I will need a unique identifier for that in order to remove duplicates. So, how can I do this without messege_id?
     
    computerzworld, Jun 24, 2009 IP
  4. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Try to create md5 of headers/body and store it in your database. This should help to differentiate each email.
     
    krishmk, Jun 25, 2009 IP
  5. adfly

    adfly Active Member

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    88
    #5
    Yes, store the MD5 of various headers/body of each email in a column in your database and use that as the 'real' unique identifier.

    You can then add a UNIQUE key on that column, so when you insert emails in to the database (with the MD5) you stop any duplicates.
     
    adfly, Jun 25, 2009 IP