GithubHelp home page GithubHelp logo

hbattat / verifyemail Goto Github PK

View Code? Open in Web Editor NEW
547.0 41.0 170.0 39 KB

PHP class that can be easily used to verify an email address and make sure it is valid and does exist on the mail server. For a supported option please visit the site

Home Page: https://hbattat.com/verifyemail.html

License: Apache License 2.0

PHP 100.00%

verifyemail's Introduction

VerifyEmail

*** IMPORTANT *** This is repo is no longer maintained.

Is a PHP class that can be easily used to verify an email address and make sure it is valid and does exist on the mail server.

This class connects to the mail server and checks whether the mailbox exists or not.

Blog posts:

Description: http://curlybrac.es/2016/07/25/verifyemail-php-class-to-validate-email-address/

How to configure mail server: http://curlybrac.es/2016/07/27/how-to-configure-a-mail-server/

How to install (using composer):

Add the package to composer.json

{
	"require": {
		"hbattat/verifyemail": "<version number>"
	}
}

Then add the autoload to your file:

require 'vendor/autoload.php';

That's all, now you are ready to use that class!

How to use:

Initialize the class:

$ve = new hbattat\VerifyEmail('[email protected]', '[email protected]');

OR (you can specify other port number than 25)

$ve = new hbattat\VerifyEmail('[email protected]', '[email protected]', 26);

The first email address '[email protected]' is the one to be checked, and the second '[email protected]' is an email address to be provided to the server. This email needs to be valid and from the same server that the script is running from. To make sure your server is not treated as a spam or gets blacklisted check the score of your server here https://mail-tester.com

Then you call the verify function:

var_dump($ve->verify());

This will return a boolean. True if the email is valid, false otherwise.

bool(true)

If you want to get any errors, call this function after the verify function:

print_r($ve->get_errors());

This will return an array of all errors (if any):

Array
(
    [0] => No suitable MX records found.
)

If you want to get all debug messages of the connection, call this function:

print_r($ve->get_debug());

This will return an array of all messages and values that used during the process.

Array
(
    [0] => initialized with Email: h*****@gmail.com, Verifier Email: [email protected], Port: 25
    [1] => Verify function was called.
    [2] => Finding MX record...
    [3] => Found MX: alt4.gmail-smtp-in.l.google.com
    [4] => Connecting to the server...
    [5] => Connection to server was successful.
    [6] => Starting veriffication...
    [7] => Got a 220 response. Sending HELO...
    [8] => Response: 250 mx.google.com at your service

    [9] => Sending MAIL FROM...
    [10] => Response: 250 2.1.0 OK gw8si3985770wjb.84 - gsmtp

    [11] => Sending RCPT TO...
    [12] => Response: 250 2.1.5 OK gw8si3985770wjb.84 - gsmtp

    [13] => Sending QUIT...
    [14] => Looking for 250 response...
    [15] => Found! Email is valid.
)

And to see the raw debug messages of the server commands sent

print_r($ve->get_debug(true));

which will return an array:

Array
(
    [helo] => 250 mx.google.com at your service
    [mail_from] => 250 2.1.0 OK a68si4170774ioe.18 - gsmtp
    [rcpt_to] => 250 2.1.5 OK a68si4170774ioe.18 - gsmtp
    [quit] => 4
)

Other Examples:

You can also modify/set the values of email to verify, verifier email, and port number on the fly after initializing

$ve->set_email('<another email Address to verify>');
$ve->set_verifier_email('<another verifier email>');
$ve->set_port(<port number>);

Notes:

  • Some mail servers will silently reject the test message, to prevent spammers from checking against their users' emails and filter the valid emails, so this function might not work properly with all mail servers.

  • You server must be configured properly as a mail server to avoid being blocked or blacklisted. This includes things like SSL, SPF records, Domain Keys, DMARC records, etc. To check your server use this tool https://mail-tester.com

verifyemail's People

Contributors

hbattat avatar spartas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

verifyemail's Issues

Server doesn't allow e-mail address verification

Hi i have problem in your script if i verify specific email "[email protected]".

ERROR: Notice: fputs(): send of 4 bytes failed with errno=32 Broken pipe
in vendor/hbattat/verifyemail/src/VerifyEmail.php at line 151 -

$this->debug[] = 'Response: '.$to;
$this->debug[] = 'Sending QUIT...';
$quit = fputs ($this->connect , "QUIT");  <<--- problem here
$this->debug_raw['quit'] = $quit;
fclose($this->connect);

Can you make some exception?
My app now crashing.. :/
Thanks

Doesn't work

It always shows "[18] => Not found! Email is invalid." and when I put gmail email, it shows additional errors:

Notice: fputs(): send of 37 bytes failed with errno=32 Broken pipe in /home/pi/languages/git/php/emails/verifyEmail/src/VerifyEmail.php on line 145

Notice: fputs(): send of 4 bytes failed with errno=32 Broken pipe in /home/pi/languages/git/php/emails/verifyEmail/src/VerifyEmail.php on line 151
bool(false)

Not found! Email is invalid for all role based email created from server.

[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] => otherdomain.com
[6] => Finding MX record...
[7] => Found MX: domain.com
[8] => Connecting to the server...
[9] => Connection to server was successful.
[10] => Starting veriffication...
[11] => Got a 220 response. Sending HELO...
[12] => Response: 220-We do not authorize the use of this system to transport unsolicited,

[13] => Sending MAIL FROM...
[14] => Response: 220 and/or bulk e-mail.

[15] => Sending RCPT TO...
[16] => Response: 250 md-in-46.webhostbox.net Hello verifyre.co [103.232.125.199]

[17] => Sending QUIT...
[18] => Looking for 250 response...
[19] => Not found! Email is invalid.

Error when running the script

Notice: Undefined index: IfExistsResult in /home/pclean1/public_html/src/VerifyEmail.php on line 285
Can you tell me what is causing this? how does the script handle exceptions?
@hbattat (great script!)
Thanks a lot!

Undefined variable: details

( ! ) Notice: Undefined variable: details in C:\Server\www_\verify-email.php on line 30
Call Stack

Time Memory Function Location

1 0.0007 353520 {main}( ) ...\verify-email.php:0
2 0.0007 353520 verifyEmail( ) ...\verify-email.php:73

Yahoo email working wrong

I try verify email: [email protected]

It return email valid.

But when i send email to this address, google response

Delivery to the following recipient failed permanently:
[email protected]
Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the server for the recipient domain yahoo.com by mta5.am0.yahoodns.net. [98.136.217.202].

The error that the other server returned was:
554 delivery error: dd This user doesn't have a yahoo.com account ([email protected]) [-5] - mta1325.mail.gq1.yahoo.com

After using this tool my IP was blocked

Hello,
after I try this tool on my localhost (10-20 emails) my IP was listed on blacklist.
Same problem on webserver - there was checking 1300 emails.

I try it before we move emailing from eshop to mailchimp.

Listed on:
Blacklist Reason TTL ResponseTime
LISTED CBL
LISTED Spamhaus ZEN ( by CBL)

Removed is simply but emails from webserver until do not sendig correctly.

Gmail validation no longer working

This lib used to work very well for me, but now it just returns bool(false) even when i go back to old codes that i've used it for, it now gives bool(false).

Error Response: 550 5.5.1 Protocol error

when I check a email from different site I have this error
[10] => Got a 220 response. Sending HELO...
[11] => Response: 250 lpn-prd-vrin019

[12] => Sending MAIL FROM...
[13] => Response: 250 2.1.0 Ok

[14] => Sending RCPT TO...
[15] => Response: 550 5.5.1 Protocol error

from this site : laposte.net ,

Yahoo verifications fail

Good morning all.
I'm facing with a big problem: cannot validate/verify yahoo email addresses different from @yahoo.com!!!
Some months ago, Yahoo stopped to register national addresses, so now you can have only "@yahoo.COM" addresses but NOT "@yahoo.IE, @yahoo.CO.UK, @yahoo.ES, etc".
As you know verifyEmail script check the address on registration page which is now configured for accepting only @yahoo.com new addresses: so if I check @yahoo.it or @yahoo.pt address... it fails!!!
Have you any idea how to solve this problem ?
Thank you in advance.
-Francesco

Email Address special characters

How does this verify addresses with multiple "@" symbols (e.g. "Tim@organization"@example.com). Additionally, does it properly validate email addresses using IP addresses (e.g. Tim@[127.0.0.1] or Tim@[IPv6:::1])?

All Emails Return as Valid..

Have you had any luck getting a response back that the email is NOT VALID mailable. If I try emails I know do not exist it still comes back as Email is Valid. My research has show that trying to determine if an email is valid (user and domain...Not just domain) does not work well.

Make constructor parameters optional

Hi,
if you have already set up methods as set_email, set_verifier_email, set_port, you cannot obly the use of constructor with non-optional $email and $verifier_email .
Let's think about it... if i speak of performances, i can reuse the same object to check multiple mail, for example in a foreach loop, using set_email method, but with this kind of constructor the first time i call the new object i am oblied to pass the first email of the array...

$emails = array('[email protected]','[email protected]','[email protected]');
$verifierEmail = '[email protected]';

//the wrong way...
$verifyEmail = new VerifyEmail(array_pop($emails),$verifierEmail);
$verifyEmail->verify();
foreach($email as $email){
    $verifyEmail->set_email($email);
    $verifyEmail->verify();
}


//the right way...
$verifyEmail = new VerifyEmail();
$verifyEmail->set_verifier_email($verifierEmail);
foreach($email as $email){
    $verifyEmail->set_email($email);
    $verifyEmail->verify();
}

How to fix?

bool(false)
Array
(
[0] => Initialized with Email: naufal****@gmail.com, Verifier Email: nauf****@naufalans.com, Port: 25
[1] => Email was set to naufal****@gmail.com
[2] => Verifier Email was set to nauf****@naufalans.com
[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 failed.
)

Incorrect TRUE return

Hi,
I checked your code and I get, I think , an incorrect behavior:

 debug($ve);

object(hbattat\VerifyEmail) {
    email => '[email protected]'
    verifier_email => '[email protected]'
    port => (int) 25
    [private] mx => null
    [private] connect => null
    [private] errors => null
    [private] debug => [
        (int) 0 => 'Initialized with Email: [email protected], Verifier Email: [email protected], Port: 25',
        (int) 1 => 'Email was set to [email protected]',
        (int) 2 => 'Verifier Email was set to [email protected]',
        (int) 3 => 'Port was set to 25'
    ]
    [private] debug_raw => []
    [private] _yahoo_signup_page_url => 'https://login.yahoo.com/account/create?specId=yidReg&lang=en-US&src=&done=https%3A%2F%2Fwww.yahoo.com&display=login'
    [private] _yahoo_signup_ajax_url => 'https://login.yahoo.com/account/module/create?validateField=yid'
    [private] yahoo_signup_page_content => null
    [private] yahoo_signup_page_headers => null
}

debug($ve->verify());

true

Why true??

Yahoo seems to reject verify

My mail server is configured correctly with DKIM and SPF, I can get a good result with gmail but when I tried at Yahoo, it always return like this:

[0] => initialized with Email: ******, Verifier Email: ******, Port: 25
[1] => Verify function was called.
[2] => Finding MX record...
[3] => Found MX: mta5.am0.yahoodns.net
[4] => Connecting to the server...
[5] => Connection to server was successful.
[6] => Starting veriffication...
[7] => Got a 220 response. Sending HELO...
[8] => Response: 220-We do not authorize the use of this system to transport unsolicited, 

[9] => Sending MAIL FROM...
[10] => Response: 220 and/or bulk e-mail.

[11] => Sending RCPT TO...
[12] => Response: 250 ****** Hello ****** [******]

[13] => Sending QUIT...
[14] => Looking for 250 response...
[15] => Not found! Email is invalid.

My mail server doesn't listed in any blacklist..

Is there any solution?

Difference?

What is the differences between this version and de paid one?
Why the pay version has no email or form to contact?

How to add this email in an array ?

I want to check 1000 emails at the same time.I have to check all email addresses in arrayinsterad of check email address one by one.So i have added one extra email in it and check 2 email addresses at the same time but code is assuming my second email as port no.So please can you tell me the solution of this how we can check 100 emails atthe same time in an array.

$ve=array();
$ve = new VE\VerifyEmail('[email protected]', '[email protected]','[email protected]','[email protected]');
print_r($ve);
for ($x = 1; $x <= 2; $x++)
{

var_dump($ve->verify());

echo '

';print_r($ve->get_debug());
}

Script fails to connect to the server for gmail emails and other domain ids.

Without modifying anything in the code, it was verifying gmail addresses till yesterday but now it does not and says connection to the server failed. What could possibly be the reason of all of a sudden failing of script? I am using Wamp to run the script.
Another question: It was not checking other domains emails like webart.pk emails. any suggested solution for that?
Thanks in Advance

Still supported?

Get a Notice regarding the $result variable

if ($getdetails) { return array($result, $details); } else { return $result; }

"<br /> <b>Notice</b>: Undefined variable: result in ... null"

Code Usage

Hi,
Under which license is this code released? Can it be used commercially?

Code is not working for yahoo and outlook

Hi Sir , I have used your code an its works for gmail but not work with yahoo and outlook.If i check the incorrect email of yahoo in it its always show it is valid email .please can you give me the solution of verify all email address from yahoo domain.This code is not working for outlook domain,messages are not sent.

Why alert me 'Fatal error: Class 'hbattat\VerifyEmail' not found'?

Fresh man fresh question:

When I run the index.php, the PHP alert me:

Fatalerror: Class 'hbattat\VerifyEmail' not found in /Applications/XAMPP/xamppfiles/htdocs/index.php on line 72

I have set composer like this:

{
    "name": "hbattat/verifyemail",
    "description": "PHP class that can be easily used to verify an email address and make sure it is valid and does exist on the mail server.",
    "type": "library",
    "require": {
        "php": ">= 5"
    },
    "require-dev": {
        "phpunit/phpunit": "^4.8.27"
    },
    "license": "Apache",
    "authors": [
        {
            "name": "Sam Battat",
            "email": "[email protected]"
        }
    ],
    "autoload": {
        "psr-4": {
            "hbattat\\": "./src"
        }
    },
  "require": {
    "hbattat/verifyemail": "<version number>"
  }
}

I guess if the <version number>I did't insert right, but I can't find the .

what shoul I do?Thx.

I can't verifier emails of database

Hello.

I have a problem. I have a data base in mysql with emails. I need verifier this emails with you script. I get the emails in php with mysqli_fetch_array but this don't run with this function. I have tried to show that result of mysli_fetch_array by screen and this show correctly the address.

If i write ane address in code this run correctly, but if i use the funcion not run.

Please, can you help me?

This is my code example:

`
require_once('verifyEmail-master/verify.class.php');

$link = mysqli_connect("xxxx", "xxxx", "xxxx", "xxxx");

$result = mysqli_query($link, "select * from correos limit 0,10");

while( $datos = mysqli_fetch_array($result) )
{
$ve = new VE\VerifyEmail($datos[correo], '[email protected]');

    if($ve->verify()==true)
    {
        echo "<br> The email $datos[correo] is correct.";
    }
    else
    {
        echo "<br> The email $datos[correo] is not correct.";
    }

}

`

Very thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.