Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with Email Sending to notification list -- STOREDRV.Submission.Exception:StoragePermanentException.MapiExceptionDuplicateDelivery #415

Open
TexasGitHubber opened this issue Sep 28, 2018 · 1 comment

Comments

@TexasGitHubber
Copy link
Contributor

This is an error we starting receiving around September 12, 2018. Our Eventum implementation is configured to use our Microsoft Office 365 email service. We suspect there was some change on the Microsoft side.

We suggest that the solution is to make each Message-ID unique before sending. We wrote the code below that works for us (can be improved, I'm sure!). We hope this can be useful for the Eventum distribution. This is a problem when there is more than one recipient attached to an Eventum Issue notification list.

The error looks like this:


[2018-09-28 16:17:31] app.ERROR: 5.2.0
STOREDRV.Submission.Exception:StoragePermanentException.MapiExceptionDuplicateDelivery;
Failed to process message due to a permanent exception with message Cannot get ID from name. 16.55847:E00E0000, 17.43559:0000000083020000000000000000000000000000,
20.52176:140F8C841B0010100A00090E, 20.50032:140F8C848B1710100A001D30,
0.35180:AC010000, 255.23226:0A004967, 255.27962:02000000, 255.27962:06000000, 
...
at /var/www/html/eventum/vendor/zendframework/zend-mail/src/Protocol/AbstractProtocol.php:327)"}
{"file":"/var/www/html/eventum/src/Mail/MailTransport.php","line":55,"class":"Eventum\\Mail\\MailTransport","function":"send","memory_usage":"7.25
MB","memory_peak_usage":"7.5 MB","version":"3.5.4","usr_id":""}

We discovered that if we uniquified the Message ID that we would not get the kick-back from Office 365.

This is what we did:


========================================================
/*
Add this Snippet to:
/var/www/html/eventum/src/Mail/MailMessage.php
Within the top of this function:
public static function createFromHeaderBody($headers, $content) 

*/
$msgIDPart = self::GetMessageIDPart($headers); 

if(!empty($msgIDPart))
{

    if(strlen($msgIDPart) > 10)
    {
        $msgIDPartUpdate = $msgIDPart . microtime(true); 

        $headers = str_replace($msgIDPart, $msgIDPartUpdate, $headers); 
        $content = str_replace($msgIDPart, $msgIDPartUpdate, $content); 

    }
}
======================================================== 

//add this function to MailMessage.php
    public static function GetMessageIDPart($header)
    {
            $headerString = " " . $header;
            $headerString =  preg_replace('/\t/', "", $headerString);
            $headerString = preg_replace( '/\r|\n/', "", $headerString );
            $headerString = preg_replace( '/Message-Id:/i', " Message-ID: ", $headerString );
            $headerString = preg_replace( '/Message-Id:  /i', " Message-ID: ", $headerString );
            $headerString = preg_replace('/>/', ">\n", $headerString);
            preg_match('/(?<=\Message-ID\: <)(.+)(?=\@)/i', $headerString, $matches);

            $idPart = '';

            if(is_array($matches))
            {
                if(count($matches) > 0)
                {
                    $idPart = $matches[0];
                }
            }

            return $idPart;
    }
========================================================

@glensc
Copy link
Member

glensc commented Sep 25, 2019

@TexasGitHubber I don't really get what you are doing here, but I added cleaner interface to set MessageId: #685

@glensc glensc modified the milestone: 3.8.3 Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants