enterdani 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.
How much?
We aren't your code slaves. You code it, post it here, and then we critique it or help you fix errors and/or problems.
cant get it to work
/*
* Send data using socket conneection
*/
protected function send($msg){
if(empty($msg)) return false;
$this->debug_txt[] = $msg;
if(!fputs($this->fsock, $msg."\n")){
$this->debug_txt[] = 'Failed to send data ';
return false;
}
$response = null;
while(1) {
$buffer = fread($this->fsock, 4096);
$response .= $buffer;
if(empty($buffer))
break;
}
//var_dump($response);
if(!empty($response)){
$this->debug_txt[] = 'Received response » '.$response;
}
return $response;
}
/**
*
* Send helo message and check mailbox
*
* @return boolean
*/
protected function ping(){
if($this->fsock){
stream_set_timeout($this->fsock, $this->data_timeout);
if(!$this->send("HELO ".$this->local_host)) return;
if(!$this->send("MAIL FROM: <".$this->local_user.'@'.$this->local_host.">")) return;
$response = $this->send("RCPT TO: <".$this->user.'@'.$this->domain.">");
// Get response code
list($code, $msg) = @explode('', $response);
$this->user = null;
$this->domain = null;
if ($code == '250') {
return true;
}else return false;
}else return;
}
/**
* Close created socket connection
*
* @return void
*/
protected function closeSocket(){
if($this->fsock){
fclose($this->fsock);
$this->fsock = false;
}
}
/**
* Verify email address if this is exists or not
*
* @return boolan
*/
public function verify($email){
$this->email = $email;
if(!$this->validatedEmail())
return 0;
if(!$this->verifyDNS())
return 0;
if(!$this->verifyMX())
return 0;
//create socket to mail host
if(!$this->createSocket())
return 0;
$finalresponse = $this->ping();
$this->closeSocket();
return $finalresponse;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.