Making WordPress.org

Changeset 12297


Ignore:
Timestamp:
12/05/2022 03:58:29 AM (3 years ago)
Author:
dd32
Message:

HelpScout: Match a few other email bounce variants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/common.php

    r11874 r12297  
    4343        $from          = strtolower( implode( ' ', array_filter( [ $email, ( $request->customer->fname ?? false ), ( $request->customer->lname ?? false ) ] ) ) );
    4444        $subject_lower = strtolower( $subject );
     45
    4546        if (
    4647            str_contains( $from, 'mail delivery' ) ||
    4748            str_contains( $from, 'postmaster' ) ||
    4849            str_contains( $from, 'mailer-daemon' ) ||
     50            str_contains( $from, 'noreply' ) ||
    4951            str_contains( $subject_lower, 'undelivered mail' ) ||
    5052            str_contains( $subject_lower, 'returned mail' ) ||
     
    5254            str_contains( $subject_lower, 'delivery status' ) ||
    5355            str_contains( $subject_lower, 'delivery report' ) ||
    54             str_contains( $subject_lower, 'mail delivery failed' )
     56            str_contains( $subject_lower, 'mail delivery failed' ) ||
     57            str_contains( $subject_lower, 'mail delivery failure' )
    5558        ) {
     59
     60
    5661            // Fetch the email.
    5762            $email_obj = Helpscout_API::api( '/v2/conversations/' . $request->ticket->id . '?embed=threads' );
     
    6772                    // Extract `To:`, `X-Orig-To:`, and fallback to all emails.
    6873                    $emails = [];
    69                     if ( preg_match( '!^(x-orig-to:|to:)\s*(.+@.+)$!im', $email_body, $m ) ) {
    70                         $m[2] = str_replace( [ '<', '>' ], '', $m[2] );
    71                         $m[2] = trim( $m[2], '<> ' );
     74                    if ( preg_match( '!^(x-orig-to:|to:|Final-Recipient:(\s*rfc\d+;)?)\s*(?P<email>.+@.+)$!im', $email_body, $m ) ) {
     75                        $m['email'] = str_replace( [ '&lt;', '&gt;' ], '', $m['email'] );
     76                        $m['email'] = trim( $m['email'], '<> ' );
    7277
    73                         $emails = [ $m[2] ];
     78                        $emails = [ $m['email'] ];
    7479                    } else {
    7580                        // Ugly regex for emails, but it's good for mailer-daemon emails.
Note: See TracChangeset for help on using the changeset viewer.