PHP and DNS. Check of the post address
Function getmxrr
string getmxrr (string hostname, array mxhost, [, array weight])
This function accepts the host name as argument
hostname
In the given domain also fills in a file
mxhost
The list of post retransmitters of this domain. If the third unessential argument weight is specified,
Function fills in that his values of preference which are returned to her with a post retransmitter
Usually when it is required to send messages to the address username@someserver.com,
It is necessary to learn{find out} all over again a host of a post retransmitter for the domain someserver.com, and then to receive his ip-address.
After that it is possible to incorporate to a host for delivery of mail.
In the domain there can be some post retransmitters with different values of preference, therefore,
Having received the list of retransmitters, it is meaningful to establish connection with that from them which has the maximal value of preference.
In the following listing the example of a code with which help it is possible to receive the list of post retransmitters is shown:
Reception of the list of post retransmitters
<?
$domain = "server.com";
getmxrr ($domain, $maillist, $priority);
echo (" the List of post retransmitters of a host $domain: <br> n ");
for ($i = 0; $i <count ($maillist), ++ $i)
{
echo (" $maillist [$i] = $priority [$i] <br> n ");
}
?>
Check of existence of an e-mail address
Let's notice at once, that the question is not check of addresses with the help of regular expression,
And about check of existence of a host of a post retransmitter for some domain.
I.e. the above mentioned code can practically not processing be adapted for check of existence e-mail addresses:
<?
$email_arr = explode (, $email);
$host = $email_arr [1];
if (! getmxrr ($host, $mxhostsarr))
{
echo " On $email address sending of mail is impossible ";
exit;
}
getmxrr ($host, $mxhostsarr, $weight);
echo " On $email letters can be sent through the following hosts: <br> ";
for ($i=0; $i <count ($mxhostsarr); $i ++)
{
echo (" $mxhostsarr [$i] = $weight [$i] <br> ");
}
?>

|