<?php connect('{imap.gmail.com:993/imap/ssl/novalidate-cert}', 'kanemfgcontactus@gmail.com', '0Gfd60uwHOJ4'))
{
$inbox = $email->getMessages('html');
}
//print_r($inbox['data']); if($inbox ==null){ echo 'not Connect'; }else{ if(count($inbox['data'])>0){ foreach($inbox['data'] as $mail){ //$statuss = imap_setflag_full($connectionn, $mail['uid'], "\\Seen \\Flagged", ST_UID); //echo $mail['message']; foreach(preg_split("/((\r?\n)|(\r\n?))/", $mail['message']) as $line){ if(strpos($line,'From:') !== false){ $Name=explode('From:',$line); // echo $Name[1]; } if(strpos($line,'Email:') !== false){ $Email=explode('Email:',$line); // echo $Email[1]; } if(strpos($line,'Subject:') !== false){ $Subject=explode('Subject:',$line); // echo $Subject[1]; } } $MessageBody = get_string_between($mail['message'], 'Message Body:', 'This e-mail was sent from a contact form on www.kanemfg.com'); /* foreach(preg_split('/<(.*?)>/u', $mail['message']) as $line){ //echo print_r($line); if(strpos($line,'Message Body:') !== false){ print_r($line); $Emaill=explode('Message Body:',$line); $Email=preg_split('/<(.*?)>/u', $Emaill[1]) ; //print_r($Email); } }*/ createContact($Name[1],$Email[1],$Subject[1],$MessageBody); } }else{ } } function createContact($Name,$Email,$Subject,$MessageBody) { die("dddd");; $msg=''; $form_url = "https://app.funnelmaker.com/xml.pl"; // This is the data to POST to the form. The KEY of the array is the name of the field. The value is the value posted. $data_to_post = array(); $data_to_post['email'] ="dev1@funnelmaker.com"; $data_to_post['password'] ="dev1"; $data_to_post['xml'] = ""; // Initialize cURL $curl = curl_init(); // Set the options curl_setopt($curl,CURLOPT_URL, $form_url); // This sets the number of fields to post curl_setopt($curl,CURLOPT_POST, sizeof($data_to_post)); // This is the fields to post in the form of an array. curl_setopt($curl,CURLOPT_POSTFIELDS, $data_to_post); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //execute the post $result= curl_exec($curl); $xml = new SimpleXMLElement($result); $tocken = $xml->Token; $success = $xml->Result; $tknerror=$xml->ErrorText; if(isset($FullName) && !empty($FullName) && isset($EmailAddress) && !empty($EmailAddress)){ $fullform=" ".ltrim(strip_tags($FullName))." ".ltrim(strip_tags($CompanyName))." ".ltrim(strip_tags($Title))." ".ltrim(strip_tags($EmailAddress))." ".ltrim(strip_tags($PhoneNumber))." ".ltrim(strip_tags($Address1))." ".ltrim(strip_tags($City))." ".ltrim(strip_tags($State))." ".ltrim(strip_tags($Zip))." ".ltrim(strip_tags($Industry))." kanemfgcontactus form ";//WARM Inbound Leads from Neuton if($success=="Success"){ $data_to_posts = array(); $data_to_posts['email'] ="dev1@funnelmaker.com"; $data_to_posts['auth_token'] = "$tocken"; $data_to_posts['xml'] = "$fullform"; /*echo ""; print_r($fullform);die;*/ // Initialize cURL $curl = curl_init(); // Set the options curl_setopt($curl,CURLOPT_URL, $form_url); // This sets the number of fields to post curl_setopt($curl,CURLOPT_POST, sizeof($data_to_posts)); // This is the fields to post in the form of an array. curl_setopt($curl,CURLOPT_POSTFIELDS, $data_to_posts); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //execute the post $resultnew= curl_exec($curl); $xmlnew = new SimpleXMLElement($resultnew); /*echo ""; print_r($xmlnew);*/ $textResult=$xmlnew->Contacts->Contact->Result; $textResulterror=$xmlnew->Contacts->Contact->ErrorText; $Contact_id=$xmlnew->Contacts->Contact->Contact_id; if($textResult=='Success'){ echo json_encode(array('status'=>200,'msg'=>'your registration Successfully')); }else{ echo json_encode(array('status'=>402,'msg'=>$textResulterror)); } }else{ echo json_encode(array('status'=>403,'msg'=>$tknerror)); } }else{ echo json_encode(array('status'=>403,'msg'=>'You did not fill out the required fields')); } } function get_string_between($string, $start, $end){ $string = ' ' . $string; $ini = strpos($string, $start); if ($ini == 0) return ''; $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); }
?>