百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
V

verifyEmail

> 编程语言
开源

PHP 类可以用于轻松验证电子邮件地址,确保其有效且存在于邮件服务器上。有关受支持的选项,请访问 th

544 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

PHP 类可以用于轻松验证电子邮件地址,确保其有效且存在于邮件服务器上。有关受支持的选项,请访问 th

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": ""
	}
}

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:

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

OR (you can specify other port number than 25)

php
$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:

php
var_dump($ve->verify());

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

xml
bool(true)

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

php
print_r($ve->get_errors());

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

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

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

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

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

…

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

php
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

php
$ve->set_email('');
$ve->set_verifier_email('');
$ve->set_port();

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

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言