套件簡介
套件名稱 | VerifyEmail |
---|---|
套件來源 | 第三方 |
Docs | https://github.com/hbattat/verifyEmail |
Laravel 版本 | 5.4.27 |
套件版本 | 1.0.7 |
安裝
composer.json
"require": {
// ...
"hbattat/verifyemail": "~1.0"
},
$ composer update
# 安裝成功
# - Installing hbattat/verifyemail (v1.0.7): Loading from cache
程式
- routing
routes\web.php
Route::get('verifyEmail', 'SendTestMail@verifyEmail');
- controller
app\Http\Controllers\SendTestMail.php
use hbattat\VerifyEmail;
public function verifyEmail()
{
$myMail = '[email protected]';
$checkMail = '[email protected]';
$ve = new VerifyEmail($checkMail, $myMail);
echo 'result: ' . $ve->verify();
}
- debug
1.調整 scope
vendor\hbattat\verifyemail\src\VerifyEmail.php
// private $debug;
public $debug;
2.debug
app\Http\Controllers\SendTestMail.php
print_r($ve->debug);
3.result
Array
(
[0] => Initialized with Email: [email protected], Verifier Email: [email protected], Port: 25
[1] => Email was set to [email protected]
[2] => Verifier Email was set to [email protected]
[3] => Port was set to 25
[4] => Verify function was called.
[5] => Finding MX record...
[6] => Found MX: gmail-smtp-in.l.google.com
[7] => Connecting to the server...
[8] => Connection to server was successful.
[9] => Starting veriffication...
[10] => Got a 220 response. Sending HELO...
[11] => Response: 250 mx.google.com at your service
[12] => Sending MAIL FROM...
[13] => Response: 250 2.1.0 OK o33si1430460plb.351 - gsmtp
[14] => Sending RCPT TO...
[15] => Response: 550-5.1.1 The email account that you tried to reach does not exist. Please try
[16] => Sending QUIT...
[17] => Looking for 250 response...
[18] => Not found! Email is invalid.
)
錯誤處理
- 驗證 yahoo 發生錯誤
vendor\hbattat\verifyemail\src\VerifyEmail.php
private function get_yahoo_cookies(){
// ...
foreach ($this->yahoo_signup_page_headers as $hdr) {
if (preg_match('/^Set-Cookie:\s*(.*?;).*?$/', $hdr, $matches)) {
$cookies[] = $matches[1];
}
// fix start
if (preg_match('/^set-cookie:\s*(.*?;).*?$/', $hdr, $matches)) {
$cookies[] = $matches[1];
}
//fix end
}
// ...
}