$re = '/^(\S+|\S+\s+\d+\s+\S+) (\S+) ?sendmail\[\d+\]: (\S+): ?(\S+)? \[(\d+\.\d+\.\d+\.\d+)] ?(\(may be forged\))? did not issue MAIL\/EXPN\/VRFY\/ETRN during connection to M(?:TA|SA)$/';
$str = 'Aug 20 04:44:21 hostname sendmail[40746]: v7K8iDNm040746: host2.example.com [10.11.101.202] (may be forged) did not issue MAIL/EXPN/VRFY/ETRN during connection to MSA';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 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