PHP Function for Sending HTTP Post Request and Extracting Emails | General Hacking | Crax

Welcome To Crax.Pro Forum!

Check our new Marketplace at Crax.Shop

   Login! SignUp Now!
  • We are in solidarity with our brothers and sisters in Palestine. Free Palestine. To learn more visit this Page

  • Crax.Pro domain has been taken down!

    Alternatives: Craxpro.io | Craxpro.com

PHP Function for Sending HTTP Post Request and Extracting Emails

PHP Function for Sending HTTP Post Request and Extracting Emails

LV
1
 

james125

Member
Joined
Nov 30, 2022
Threads
14
Likes
42
Awards
4
Credits
14,875©
Cash
1$
The following PHP function can be used to send an HTTP post request and extract emails from an unstructured string. It also includes functions for validating an email address and a domain name.

PHP:
<?php
function sendHttpRequest($url, $data) {
  // Create the context
  $context = stream_context_create(array(
    'http' => array(
      'method' => 'POST',
      'header' => 'Content-type: application/x-www-form-urlencoded',
      'content' => http_build_query($data)
    )
  ));

  // Send the request
  return file_get_contents($url, false, $context);
}

function extractEmails($string) {
  $emails = array();
  preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
  if (isset($matches[0])) {
    foreach ($matches[0] as $email) {
      if (validateEmail($email)) {
        $emails[] = $email;
      }
    }
  }
  return $emails;
}

function validateEmail($email) {
  if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
    // Split the email address into the username and domain
    list($username, $domain) = explode('@', $email);
    // Validate the domain
    if (validateDomain($domain)) {
      return true;
    }
  }
  return false;
}

function validateDomain($domain) {
  if (checkdnsrr($domain, 'MX')) {
    return true;
  }
  return false;
}

?>

That's it! Now you can use these functions to send HTTP post requests, extract emails from unstructured strings, validate email addresses, and validate domain names. 🤓
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Top Bottom