0

I want to find website email address(like name@example.com) from website url link.
so, is it possible to find email address from website url ?
if yes then, please share how to implement.
Language is not necessary.

as per my view,
if we read content from website url using CURL, and
find email address from them using regular expression.
is it possible ?

find bellow code for read page content from website url using CURL:

<?php
$url = 'yoururl';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);

after then find email address using regex expression from $data string.

Is it possible ?

Vishal Khunt
  • 172
  • 3
  • 14

2 Answers2

3

Technically you could get an email address from a domain by querying the public WHOIS information (which could be done by querying an API) but the email address publicised are rarely a companies true email address but rather reporting mailboxes for spam or technical requests.

http://network-tools.com/default.asp?prog=network&host=www.google.com

Some example code of how it could be done returning JSON output:

<?php

function getIP() {

   if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
     $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
     $ip = $_SERVER['REMOTE_ADDR'];
    }

    return chkIP($ip);

}

function chkIP($ip) {

     $dirtydomain = gethostbyaddr($ip);
     preg_match("/((\w*)\.+(\w{2})\.+(\w{2})$)|((\w*)\.+(\w{3})$)/", $dirtydomain, $output_array);
     $cmd = 'whois ' . $output_array[0];
     $data = shell_exec($cmd);

     return getEmail($data,$output_array[0]);

}


function getEmail($data,$domain) {

    $array = preg_split('/( )|(\n)/',$data); //DATA from WHOIS

        foreach ($array as $value) {

            if (strpos($value, '@') == TRUE) {

                    $emailArray[] = $value;

            } 
        }

        return outputArray($emailArray,$domain);
}



function outputArray($emailArray, $domain) {

        if (count($emailArray) < 1) {

           return json_encode("No Email Address Found for " . $domain);

        } else {

           return json_encode($emailArray);

        }

}

getIP(); //Will Return JSON Output


?>
Kitson88
  • 2,889
  • 5
  • 22
  • 37
2

An easy regexp on the top of my head.

preg_match_all("/([a-z0-9\.]{1,50}@[a-z0-9]{1,50}\.[a-z]{1,5})/ims",$data,$matches)
Patrik Grinsvall
  • 584
  • 1
  • 4
  • 22