Announcement

Collapse
No announcement yet.

Email duplicates created by system

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Email duplicates created by system

    Hello,

    yesterday we changed our email provider to amazon work mail.

    Since we have changed it, we are facing issues that when we send an email, a duplicate is created by the system. This is happening with both inbound and outbound mails.

    We deleted the original Personal email account and added the new one. Also, the email address of each user has been rewritten in their account, and then Cache was cleared.

    Do you guys have any idea what could be wrong, please?
    When someone sends an email to me, I got it twice in my inbox, 1 created by the sender, and 1 created by the system.
    Also when I send an email, I have it shown twice in my "sent" folder.

    Thanks a lot for the help!

    edit: This is happening only when we are sending emails from CRM to CRM, it is not creating duplicates when we send emails from Outlook to CRM for example.
    Attached Files
    Last edited by Jakub Grufik; 11-09-2022, 07:42 AM.

  • #2
    Hi Jakub,

    Check what message-IDs imported duplicates have (table email > column message_id). It could be that your SMTP (or maybe IMAP?) changes message IDs and Espo can't detect that it's a duplicate. Espo checks duplicates only by message-ID.

    Comment


    • #3
      There will be the ability to bind a custom implementation of the duplicate finder in the next version.

      https://github.com/espocrm/espocrm/b...nding.php#L249

      https://github.com/espocrm/espocrm/b...cateFinder.php

      Comment


      • #4
        Likely, that SMTP adds a header with an original message-ID (Microsoft adds X-Microsoft-Original-Message-ID header). The idea is to check this ID too.

        PHP Code:
            public function find(Email $emailMessage $message): ?Email
            
        {
                $messageIds 
        = [];

                if (
        $email->getMessageId()) {
                    
        $messageIds[] = $email->getMessageId();
                }

                if (
        $message->getHeader('X-Microsoft-Original-Message-ID')) {
                    
        $messageIds[] = $message->getHeader('X-Microsoft-Original-Message-ID');
                }

                if (
        $messageIds === []) {
                    return 
        null;    
                }


                
        return $this->entityManager
                    
        ->getRDBRepositoryByClass(Email::class)
                    ->
        select(['id''status'])
                    ->
        where([
                        
        'messageId' => $messageIds,
                    ])
                    ->
        findOne();
            


        But this will be possible only in v7.3.

        Comment


        • #5
          Hello,
          yeah both emails have different message_id.

          I am not sure if I understand correctly, but at the moment we are not able to fix this unless the email provider stops changing the ids of the message(that is probably not going to happen), correct?

          Comment


          • #6
            Correct. Without making modifications to code (that won't work after upgrade) there's no way. But as of v7.3 there's a way. Can you check a message original (raw contents of an email) of any of such emails (in any email client or web interface of your mail provider). Whether it contains an original message ID header.

            Comment


            • #7
              Hey yuri thanks a lot for the explanation and information.

              Will pass this info to our email administrator to find out what could be done about this behavior.

              Have a nice day sir!

              Comment

              Working...
              X