My web host has closed off port 25 to user code as it was being used by other users to send spam. Unfortunately, I have the following code which I use to validate email addresses:
function fixed_gethostbyname ($host) {
// Try the lookup as normal...
$ip = gethostbyname($host);
// ...but if it fails, FALSE is returned instead of the unresolved host
if ($ip != $host) { return $ip; } else return false;
}
function verifyemail() {
global $domain, $username, $email, $HTTP_HOST;
$domainexists = fixed_gethostbyname($domain);
$mxexists = checkdnsrr("$domain.", 'MX');
if (!$domainexists && !$mxexists) return false;
else if (!$mxexists) return false;
else {
if (getmxrr($domain, $MXHost)) {
$ConnectAddress = $MXHost[0];
} else {
$ConnectAddress = $domain;
}
$Connect = @fsockopen ( $ConnectAddress, 25 );
if ($Connect) {
if (ereg("^220", $Out = fgets($Connect, 1024))) {
fputs ($Connect, "HELO $HTTP_HOST\r\n");
$Out = fgets ( $Connect, 1024 );
fputs ($Connect, "MAIL FROM: <{$email}>\r\n");
$From = fgets ( $Connect, 1024 );
fputs ($Connect, "RCPT TO: <{$email}>\r\n");
$To = fgets ($Connect, 1024);
fputs ($Connect, "QUIT\r\n");
fclose($Connect);
if (!ereg ("^250", $From) || !ereg ( "^250", $To )) {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
return true;
}
Yes I know there's better code, but this does the trick for me well enough for now. The problem is that it doesn't do the trick any more, because port 25 is closed.
Is there a way within PHP to have my message leave on another port, say 625, and arrive at port 25 at the other end?