如何使用PHP对SMTP服务器执行ping命令并检查MX记录?

问题描述:

如何使用PHP对SMTP服务器执行ping命令并检查MX记录?我愿意编写一个脚本,例如可以在 http://bit.ly/z4RE上找到的脚本>

How to, using PHP, ping an SMTP server and check MX records? I'm willing to write a script such as the one that can be found on http://bit.ly/z4RE

我已经将aaa@mailinator.com用作测试邮件,这是更易读的格式的结果:

I've used aaa@mailinator.com as the test mail and this is the result in more human-readable format:

Result: Ok

Log:
MX record about mailinator.com exists.
Connection succeeded to mailinator.com SMTP.
220 mail.sogetthis.com ESMTP Postfix
> HELO verify-email.org
250 Hello
> MAIL FROM: <check@verify-email.org>
=250 OK
> RCPT TO: <aaa@mailinator.com>
=250 OK

我知道必须在服务器上打开端口25.

I know that port 25 must be open on the server.

要获取与给定Internet主机名相对应的MX记录,可以使用

To get MX records corresponding to a given Internet host name you can use getmxrr:

bool getmxrr ( string $hostname , array &$mxhosts [, array &$weight ] )

要通过SMTP与邮件服务器通信,可以使用 PEAR的Net_SMTP软件包. >

To communicate with the mail server via SMTP, you can use PEAR'S Net_SMTP package.

mixed Net_SMTP::vrfy ( string $string )

该软件包还具有 HELO,MAIL FROM和RCPT TO方法