HI all
First I must say that I am not sure how PHP and STMP work together so bear with me.
I want to check whether an email address exists or not using PHP? and to get information about the owner of the email address?
I have read the following:
Let us say I have an email address
myname@mydomain.comFirstly within PHP you can validate an email by using filter_var like so:
$is_valid = filter_var("myname@mydomain.com",FILTER_VALIDATE_EMAIL);
Secondly you would want to check if the domain runs a email server, to do this you can check the dns records for MX like so:
$has_dns_mx_record = checkdnsrr("myname@mydomain.com","MX");
I understand the above to some point.
Now this is where I have trouble:
You want to open the port on the domain like so:
$socket = fsockopen("myname@mydomain.com", 25);
$mail_running = (bool)$socket;
fclose($socket);
- $socket = fsockopen("myname@mydomain.com", 25);
- $mail_running = (bool)$socket;
- fclose($socket);
You can also check to see if the SMTP Server responds with a 550, i.e email does not exist, like so:
SEND > helo hi
250 myname@mydomain.com
SEND > mail from: <youremail@yoursite.com>
250 2.1.0 Ok
SEND > rcpt to: <myname@mydomain.com>
> 550 5.1.1 <myname@mydomain.com>: Recipient address rejected: User unknown in local recipient table
- SEND > helo hi
- 250 myname@mydomain.com
- SEND > mail from: <youremail@yoursite.com>
- 250 2.1.0 Ok
- SEND > rcpt to: <myname@mydomain.com>
- > 550 5.1.1 <myname@mydomain.com>: Recipient address rejected: User unknown in local recipient table
Looking at the above you can send commands to a valid smtp server such as helo > mail from <...> and check the 550 response.
My question is how do I put this all together with PHP.
Below is a sample I have seen using some online web tools.
Checking server mx1.megamailservers.com...
Opening up socket to mx1.megamailservers.com... Success!
mx1.megamailservers.com replied: 220 mail3c0.megamailservers.com ESMTP Sendmail 8.13.6/8.13.1; Thu, 16 Aug 2012 03:21:00 -0400
HELO example.com
250 mail3c0.megamailservers.com Hello 009ip.my-addr.com [10.10.10.10], pleased to meet you
(135.70 ms)
MAIL FROM: <example@example.com>
250 2.1.0 <example@example.com>... Sender ok
(189.09 ms)
RCPT TO: <myname@mydomain.com>
250 2.1.5 <myname@mydomain.com>... Recipient ok
(152.57 ms)
QUIT
221 2.0.0 mail3c0.megamailservers.com closing connection
(134.76 ms)
- Checking server mx1.megamailservers.com...
- Opening up socket to mx1.megamailservers.com... Success!
- mx1.megamailservers.com replied: 220 mail3c0.megamailservers.com ESMTP Sendmail 8.13.6/8.13.1; Thu, 16 Aug 2012 03:21:00 -0400
- HELO example.com
- 250 mail3c0.megamailservers.com Hello 009ip.my-addr.com [10.10.10.10], pleased to meet you
- (135.70 ms)
- MAIL FROM: <example@example.com>
- 250 2.1.0 <example@example.com>... Sender ok
- (189.09 ms)
- RCPT TO: <myname@mydomain.com>
- 250 2.1.5 <myname@mydomain.com>... Recipient ok
- (152.57 ms)
- QUIT
- 221 2.0.0 mail3c0.megamailservers.com closing connection
- (134.76 ms)
I am hoping to get a PHP script that will do something similar to the above.
Thanks