Getting unique email id with IMAP in PHP

How can I calculate a unique identifier string for each letter in an IMAP account?

I am creating a script that should often copy all missing messages from one IMAP account to another. I want to avoid duplication with every update, so I have to determine what is on one account and what is on another.

Not all emails have message_id , and I don’t see the difference between message_id and uid - can someone tell me?

It seems to me that message_id does not change when using imap_append - can anyone confirm this?

When creating a unique identifier string for each letter, there are many other options than just the message identifier, name and date of the e-mail fx, but I do not know what to choose: http://www.php.net/manual/en/function.imap -headerinfo.php

+7
source share
2 answers

The UID is unique in the mailbox, but does not display between mailboxes, so it is not suitable for matching letters between mailboxes.

message_id is designed to be globally unique for all emails and is generated by the email sending server. If the server is configured correctly, each sent message will have message_id, and this can be used to map e-mail through mailboxes. However, poorly configured servers cannot assign message_id. In this case, the hash of senderaddress and udate has always been unique to me - if emails came from the same person in the same microseconds, it will be the same message. Note. Using a sender rather than from - from can be faked easier than a sender.

+9
source

for me a unique identifier can be generated as follows:

key: epoch time of mail (from date field)

But at the same time, the user can receive several letters.

key: epoch time of mail + MailSize

At a certain time, the receiver identifier can receive different letters of the same size

KEY: epoch time of mail + MailSize + Recieveing ​​IP address of the server (can be obtained from the field: received):

At a certain time, the receiver identifier can receive different messages of the same size from the same ip.

key: epoch time of mail + MailSize + Recieveing ​​IP address of the server (can receive from the received: field) + md5sum mail.

The duplication possibility for this key is very very low.

The message identifier is usually the identifier of the device that sent the message, or it may be something else, it depends entirely on the domain and may be the same for different letters and may not exist at all.

uid is what the imap server monitors for mail identity. but if the mail was deleted or moved between them, as well as the server code, it is possible that other mail can be assigned with the same uid.

+2
source

All Articles