1

このPHP関数は正常に機能しています。

if (preg_match ("/<(\S+@\S+\w)>.*\n?.*55[0-9]/i",$body,$match)) {
echo "found!";
}

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

xxx@hotmail.com
SMTP error from remote mail server after RCPT TO:<xxx@hotmail.com>:
host mx3.hotmail.com [65.54.188.72]: 550 Requested action not taken:
mailbox unavailable

しかし、この場合、同じphp関数を使用すると:

A message that you sent could not be delivered to one or more of its 
recipients. This is a permanent error. The following address(es) failed:

xxx@yahoo.com
SMTP error from remote mail server after end of data:
host d.mx.mail.yahoo.com [209.191.88.254]: 554 delivery error:
dd This user doesn't have a yahoo.com account (xxxd@yahoo.com) [0] -  mta1010.mail.mud.yahoo.com

このpreg_match関数は結果を出しません。私は何が間違っているのですか?

4

2 に答える 2

4

<あなたは基本的にとで囲まれたメールアドレスを探しています>

最初の入力にはそれがありますが、2番目の入力にはありません。電子メールID< >がないため、一致するものはありません。

編集:(コメントの後):

提供された2つのサンプルを見ると、文字列failed:と。で始まるエラーコードの間にメールIDが表示されます55。これには、次のようにpreg_matchを利用できます。

if(preg_match('/failed:.*?(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b).*55[\d]/is',$str,$m)) {
       echo "Bounced email ".$m[1]."\n";
}

イデオネリンク

于 2010-12-01T16:32:54.173 に答える
0

デフォルトでは、preg_matchは複数行の文字列(\ nを含む文字列)の解析をサポートしていないため、文字列全体(m(複数行))に一致する追加のパラメーターを渡す必要があります。

試す

if (preg_match ("/<(\S+@\S+\w)>.*\n?.*55[0-9]/im",$body,$match)) {
echo "found!";
}
于 2010-12-01T16:24:27.990 に答える