定制 peoplefone/mail-validator-mx-server 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

peoplefone/mail-validator-mx-server

Composer 安装命令:

composer require peoplefone/mail-validator-mx-server

包简介

Validate e-mail addresses by connecting to the remote MX server.

README 文档

README

This package allows you to define e-mail addresses to verify them via the corresponding remote MX server.

The validation returns an array of objects containing:

  • E-mail address
  • MX domain(s)
  • MX response code
  • MX response message

Installation

composer require peoplefone/mail-validator-mx-server

How it works

These are the requests and responses with the remote MX server.

telnet mx.domain.com 25
Trying 66.96.140.73...
Connected to mx.domain.com.
Escape character is '^]'.
220 bosimpinc12 bizsmtp ESMTP server ready
helo mydomain.com
250 bosimpinc12 hello [95.128.x.x], pleased to meet you
MAIL FROM: <me@mydomain.com>
250 <me@mydomain.com> sender ok
RCPT TO: <test@domain.com>
250 <test@domain.com> recipient ok
quit
221 bosimpinc12 bizsmtp closing connection

Example

Basic Usage

require("vendor/autoload.php");

use peoplefone\mailValidatorMXServer;

$class = new mailValidatorMXServer("mydomain.com", "me@mydomain.com");

$class->setContact("noreply@hotmail.com");
$class->setContact("noreply@gmail.com");
$class->setContact("noreply@yahoo.com");

$result = $class->validate();
print_r($result);

Result

The returned codes correspond to the RFC5321.

https://tools.ietf.org/html/rfc5321

For ordinary use, it can be assumed that the e-mail address is valid when code 250 is returned.

Array
(
    [0] => stdClass Object
        (
            [mail] => noreply@gmail.com
            [host] => Array
                (
                    [0] => gmail-smtp-in.l.google.com
                    [1] => alt1.gmail-smtp-in.l.google.com
                    [2] => alt2.gmail-smtp-in.l.google.com
                    [3] => alt3.gmail-smtp-in.l.google.com
                    [4] => alt4.gmail-smtp-in.l.google.com
                )

            [code] => 550
            [text] => Requested action not taken: mailbox unavailable (e.g., mailbox not found, no access, or command rejected for policy reasons)
        )

    [1] => stdClass Object
        (
            [mail] => noreply@hotmail.com
            [host] => Array
                (
                    [0] => hotmail-com.olc.protection.outlook.com
                )

            [code] => 250
            [text] => Requested mail action okay, completed
        )

    [2] => stdClass Object
        (
            [mail] => noreply@yahoo.com
            [host] => Array
                (
                    [0] => mta7.am0.yahoodns.net
                    [1] => mta6.am0.yahoodns.net
                    [2] => mta5.am0.yahoodns.net
                )

            [code] => 250
            [text] => Requested mail action okay, completed
        )

)

Settings Functions

/**
 * Port of the remove MX Server.
 */
$class->setConnectionPort("25");

/**
 * Timeout of each connection.
 */
$class->setConnectionTimeOut("30");

/**
 * Timeout of each communication.
 * Note that some MX servers are configured to wait before responding or respond with multiple lines.
 * Perhaps you need to increase the stream timeout to get successful validation.
 */
$class->setStreamTimeOut("15");

/**
 * Pass the Boolean value TRUE to print the debug log.
 */
$class->validate(true);

Contact Functions

$class->setContact("noreply@gmail.com");

$class->unsetContact("noreply@gmail.com");

$class->getContacts()

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固