function ehlo($conn = null, $host = null, $debug = null) { if (!FUNC4::is_debug($debug)) { $debug = debug_backtrace(); } global $_RESULT; $_RESULT = $err = array(); if (!is_resource($conn)) { $err[] = 'invalid resource connection'; } if (!is_string($host)) { $err[] = 'invalid host type'; } else { $host = strtolower(trim($host)); if (!($host != '' && ($host == 'localhost' || FUNC4::is_ipv4($host) || FUNC4::is_hostname($host, true, $debug)))) { $err[] = 'invalid host value'; } } if (count($err) > 0) { FUNC4::trace($debug, implode(', ', $err)); } else { $ret = false; $_smtp = new SMTP4(); if (!fwrite($conn, 'EHLO ' . $host . $_smtp->CRLF)) { $_RESULT[307] = 'can not write'; } else { if (!SMTP4::_cres($conn, $resp, 250, null, $debug)) { $_RESULT[308] = $resp; } else { $_RESULT[309] = $resp; $ret = true; } } return $ret; } }
function connect($host = null, $user = null, $pass = null, $port = null, $vssl = null, $tout = null, $context = null, $debug = null) { if (!FUNC4::is_debug($debug)) { $debug = debug_backtrace(); } global $_RESULT; $_RESULT = array(); $_pop3 = new POP34(); if ($port == null) { $port = $_pop3->PORT; } if ($tout == null) { $tout = $_pop3->TOUT; } $err = array(); if (!is_string($host)) { $err[] = 'invalid host type'; } else { if (!(trim($host) != '' && (FUNC4::is_ipv4($host) || FUNC4::is_hostname($host, true, $debug)))) { $err[] = 'invalid host value'; } } if (!is_string($user)) { $err[] = 'invalid username type'; } else { if (($user = FUNC4::str_clear($user)) == '') { $err[] = 'invalid username value'; } } if (!is_string($pass)) { $err[] = 'invalid password type'; } else { if (($pass = FUNC4::str_clear($pass)) == '') { $err[] = 'invalid password value'; } } if (!(is_int($port) && $port > 0)) { $err[] = 'invalid port value'; } if ($vssl != null) { if (!is_string($vssl)) { $err[] = 'invalid ssl version type'; } else { $vssl = strtolower($vssl); if (!($vssl == 'tls' || $vssl == 'ssl' || $vssl == 'sslv2' || $vssl == 'sslv3')) { $err[] = 'invalid ssl version value'; } } } if (!(is_int($tout) && $tout > 0)) { $err[] = 'invalid timeout value'; } if ($context != null && !is_resource($context)) { $err[] = 'invalid context type'; } if (count($err) > 0) { FUNC4::trace($debug, implode(', ', $err)); } else { $_pop3 = new POP34(); $ret = false; $prt = $vssl == null ? 'tcp' : $vssl; $conn = $context == null ? fsockopen($prt . '://' . $host, $port, $errno, $errstr, $tout) : fsockopen($prt . '://' . $host, $port, $errno, $errstr, $tout, $context); if (!$conn) { $_RESULT[401] = $errstr; } else { if (!socket_set_timeout($conn, $_pop3->COUT)) { $_RESULT[402] = 'could not set socket timeout'; } else { if (!POP34::_ok($conn, $resp, $debug)) { $_RESULT[403] = $resp; } else { $ret = POP34::auth($conn, $user, $pass, $debug); } } } if (!$ret) { if (is_resource($conn)) { @fclose($conn); } $conn = false; } return $conn; } }
function is_mail($addr = null, $vermx = false, $debug = null) { if (!FUNC4::is_debug($debug)) { $debug = debug_backtrace(); } $err = array(); if (!is_string($addr)) { $err[] = 'invalid address type'; } if (!is_bool($vermx)) { $err[] = 'invalid MX type'; } if (count($err) > 0) { FUNC4::trace($debug, implode(', ', $err)); } else { $ret = count($exp = explode('@', $addr)) === 2 && $exp[0] != '' && $exp[1] != '' && FUNC4::is_alpha($exp[0], true, '_-.') && (FUNC4::is_hostname($exp[1]) || FUNC4::is_ipv4($exp[1])); if ($ret && $vermx) { if (FUNC4::is_ipv4($exp[1])) { $ret = false; } else { $ret = FUNC4::is_win() ? FUNC4::getmxrr_win($exp[1], $mxh, $debug) : getmxrr($exp[1], $mxh); } } return $ret; } }
function name($host = null, $debug = null) { if (!FUNC4::is_debug($debug)) { $debug = debug_backtrace(); } if (!is_string($host)) { FUNC4::trace($debug, 'invalid hostname type'); } else { $host = strtolower(trim($host)); if (!($host != '' && ($host == 'localhost' || FUNC4::is_ipv4($host) || FUNC4::is_hostname($host, true, $debug)))) { FUNC4::trace($debug, 'invalid hostname value'); } $this->Name = $host; return $this->_result(array(0 => 'set HELO/EHLO hostname'), true); } }