summaryrefslogtreecommitdiff
path: root/mail.class
diff options
context:
space:
mode:
authorChristian Schneider2007-01-04 17:54:22 +0000
committerChristian Schneider2007-01-04 17:54:22 +0000
commitce579f09143160e84aba768bc38054d09a11063f (patch)
treec47da11fce2c1574af2353870d35f12fef939fcf /mail.class
parent5b29e1817f32454d79c3efa9d2a7688d00a85fbd (diff)
downloaditools-ce579f09143160e84aba768bc38054d09a11063f.tar.gz
itools-ce579f09143160e84aba768bc38054d09a11063f.tar.bz2
itools-ce579f09143160e84aba768bc38054d09a11063f.zip
Fix email_check for servers using greylisting
Diffstat (limited to 'mail.class')
-rw-r--r--mail.class13
1 files changed, 8 insertions, 5 deletions
diff --git a/mail.class b/mail.class
index 08006cc..b033770 100644
--- a/mail.class
+++ b/mail.class
@@ -327,23 +327,26 @@ function fullname_escape($string)
* @param $fp Connection to SMTP server opened using fsockopen
* @param $command Command to send, e.g. HELO gna.ch
* @param $anwer String containing full answer from SMTP server
- * @return True if SMTP result code is 2XX
+ * @param timeoutok Whether a timeout is considered ok
+ * @param $failcode Lowest SMTP result code which is considered a failure (default 300)
+ * @return True if SMTP result code is lower than $failcode
*
*/
-function send_smtp_cmd($fp, $cmd, &$answer, $timeoutok = false)
+function send_smtp_cmd($fp, $cmd, &$answer, $timeoutok = false, $failcode = 300)
{
$result = false;
$answer = '';
if (!$cmd || (!feof($fp) && fwrite($fp, "$cmd\r\n")))
{
- while (!feof($fp) && ereg('^(.)..(.?)(.*)$', fgets($fp, 1024), $regs))
+ while (!feof($fp) && ereg('^(...)(.?)(.*)$', fgets($fp, 1024), $regs))
{
$answer .= $regs[0];
+ $resultcode = intval($regs[1]);
if ($regs[2] != '-') /* Multi line response? */
{
- if ($regs[1] == 2)
+ if (($resultcode >= 100) && ($resultcode < $failcode))
$result = true;
break;
@@ -442,7 +445,7 @@ function check_email($email, $checkmailbox = true)
$timeout($fp, 2);
$timeoutok = ($domain != 'bluewin.ch');
- if (it_mail::send_smtp_cmd($fp, "RCPT TO: <$email>", $answer, $timeoutok))
+ if (it_mail::send_smtp_cmd($fp, "RCPT TO: <$email>", $answer, $timeoutok, 500)) # 450 is often used for Greylisting
$result = IT_MAIL_CHECKEMAIL_OK;
else if (eregi('quota|full|exceeded storage', $answer))
$result = IT_MAIL_CHECKEMAIL_MAILBOXFULL;