PHPMailerの私のアドレスバリデーターに問題があります。誰かが有効なもので私を助けることができますか?私のPHPバージョンは5.6.19であり、PHPMailerのバージョンは5.2.16なので、基本的に選択されたライブラリはpcre8です。ちっぽけなエンコード:有効なPCRE8ライブラリPHPMailerバージョン5.2.16およびPHPバージョン5.6.19
return (boolean)preg_match(
'/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
'((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
'(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
'([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' .
'(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' .
'(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' .
'|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' .
'|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' .
'|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
$address
);
send.php:
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
require_once('class.phpmailer.php');
$to=isset($_POST['verify'])?$_POST['verify']:false;
$subject="Email verification";
$message='<p>Welcome to Our service this is an email verification procedure, Please click <a href="#">here</a> to go back.';
//$to= "[email protected]";
$mail = new PHPMailer();
$mail->isSMTP(); // telling the class to use SMTP
// SMTP Configuration
$mail->SMTPSecure='ssl';
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.gmail.com "; // SMTP server
$mail->Username = "[email protected]";
$mail->Password = "mypassword";
$mail->Port = 465; // optional if you don't want to use the default
$mail->From = "<[email protected]>";
$mail->FromName = "Admin";
$mail->Subject = $subject;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->isHTML(true);
$mail->Body=$message;
$mail->msgHTML($message);
$mail->addAddress($to);
if(!$mail->Send())
{
$response = "Message error!".$mail->ErrorInfo;
echo $response;
// echo $to;
}
else {
$response = "Message sent!";
echo $response;
}
?>
ありがとう!
これはかなり正規表現です。 PHPで電子メールを検証する際の他のスレッドを見てきましたか? http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php – chris85
これは、正規表現を使用して電子メールアドレスの検証に関する一般的な質問ではありません。それはPHPMailer内の検証メカニズムに関するものです。 – Synchro
@シンクロこの違いはどうですか? PHPMailerは検証のために正規表現を使用しているようですが、質問は文字通りこの検証のための有効な正規表現を求めています。 –