$re = '/Original-Recipient: [^;]+; (?<email>[^\n]+)/';
$str = 'This is an automatically generated message from SendGrid.
We are sorry to tell you that your email was unable to be
delivered to one of its intended recipients.
If you require assistance with this, please contact SendGrid support.
Access denied - .102 listed by multiple RBL providers at the same time.
X-SendGrid-Sender: Paul Read paul@mydomain.com
Arrival-Date: Wed, 27 Mar 2024 18:26:16 +0000
Final-Recipient: rfc822; mickey@somedomain.com
Original-Recipient: rfc822; mickey@somedomain.com
Action: failed
Status: 159.183.224
Diagnostic-Code: 550 Access denied - 159.183.224.102 listed by multiple RBL providers at the same time.';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php