Skip to content

PHP function to verify if the email is valid by connecting to the mail server and checking the result.

License

Notifications You must be signed in to change notification settings

alekperos/verifyEmail

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

emailVerify

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

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

How to use:

Simply call the function:

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 (just for testing, but would be better if it is a valid email)

This will restun a string "valid" if the email [email protected] is valid, and "invalid" if the email is invalid

If you want to get the the actual details of that connection, add another parameter to the function:

print_r(verifyEmail('[email protected]', '[email protected]', true));

This will resturn an array that looks like this:

Array ( [0] => invalid [1] => 250 mx.google.com at your service 250 2.1.0 OK u4si6155213qat.124 - gsmtp 550-5.1.1 The email account that you tried to reach does not exist. Please try )

Notes:

  • Some mail servers will silentlty 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.

About

PHP function to verify if the email is valid by connecting to the mail server and checking the result.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published