From: lkehresman Date: Thu, 6 Jan 2000 18:26:28 +0000 (+0000) Subject: Rewrote SMTP functions, now includes error correction, fixed bugs in theme X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3021b626f1e78d9e02ddc0fd6cf6606b0dca1c77;p=squirrelmail.git Rewrote SMTP functions, now includes error correction, fixed bugs in theme selection on personal preferences. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@109 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/config/config.php b/config/config.php index a2541696..04ef87a8 100644 --- a/config/config.php +++ b/config/config.php @@ -50,7 +50,7 @@ $theme[3]["NAME"] = "Slashdot"; -// Whether or not to use $color[11] for special folders. If not, special +// Whether or not to use a special color for special folders. If not, special // folders will be the same color as the other folders $use_special_folder_color = true; diff --git a/functions/prefs.php b/functions/prefs.php index 5a2a89d4..51265242 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -8,6 +8,11 @@ /** returns the value for $string **/ function getPref($username, $string) { $filename = "../data/$username.pref"; + if (!file_exists($filename)) { + echo "Preference file \"$filename\" not found. Exiting abnormally"; + exit; + } + $file = fopen($filename, "r"); /** read in all the preferences **/ diff --git a/functions/smtp.php b/functions/smtp.php index 6a2e2ff5..20147405 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -18,7 +18,6 @@ function sendMessage($smtpServerAddress, $smtpPort, $username, $domain, $t, $c, $b, $subject, $body, $version) { include("../config/config.php"); - include("../functions/prefs.php"); $to = parseAddrs($t); $cc = parseAddrs($c); @@ -40,6 +39,7 @@ exit; } $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); $to_list = getLineOfAddrs($to); $cc_list = getLineOfAddrs($cc); @@ -47,28 +47,34 @@ /** Lets introduce ourselves */ fputs($smtpConnection, "HELO $domain\n"); $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); /** Ok, who is sending the message? */ fputs($smtpConnection, "MAIL FROM:$from_addr\n"); $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); /** send who the recipients are */ for ($i = 0; $i < count($to); $i++) { fputs($smtpConnection, "RCPT TO:<$to[$i]>\n"); $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); } for ($i = 0; $i < count($cc); $i++) { fputs($smtpConnection, "RCPT TO:<$cc[$i]>\n"); $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); } for ($i = 0; $i < count($bcc); $i++) { fputs($smtpConnection, "RCPT TO:<$bcc[$i]>\n"); $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); } /** Lets start sending the actual message */ fputs($smtpConnection, "DATA\n"); $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + errorCheck($tmp); fputs($smtpConnection, "Subject: $subject\n"); // Subject fputs($smtpConnection, "From: $from\n"); // Subject @@ -86,9 +92,109 @@ fputs($smtpConnection, ".\n"); // end the DATA part $tmp = nl2br(htmlspecialchars(fgets($smtpConnection, 1024))); + $num = errorCheck($tmp); + if ($num != 250) { + echo "ERROR
Message not sent!
Reason given: $tmp
"; + } fputs($smtpConnection, "QUIT\n"); // log off fclose($smtpConnection); } + + + function errorCheck($line) { + // Status: 0 = fatal + // 5 = ok + + $err_num = substr($line, 0, strpos($line, " ")); + switch ($err_num) { + case 500: $message = "Syntax error; command not recognized"; + $status = 0; + break; + case 501: $message = "Syntax error in parameters or arguments"; + $status = 0; + break; + case 502: $message = "Command not implemented"; + $status = 0; + break; + case 503: $message = "Bad sequence of commands"; + $status = 0; + break; + case 504: $message = "Command parameter not implemented"; + $status = 0; + break; + + + case 211: $message = "System status, or system help reply"; + $status = 5; + break; + case 214: $message = "Help message"; + $status = 5; + break; + + + case 220: $message = "Service ready"; + $status = 5; + break; + case 221: $message = "Service closing transmission channel"; + $status = 5; + break; + case 421: $message = "Service not available, closing chanel"; + $status = 0; + break; + + + case 250: $message = "Requested mail action okay, completed"; + $status = 5; + break; + case 251: $message = "User not local; will forward"; + $status = 5; + break; + case 450: $message = "Requested mail action not taken: mailbox unavailable"; + $status = 0; + break; + case 550: $message = "Requested action not taken: mailbox unavailable"; + $status = 0; + break; + case 451: $message = "Requested action aborted: error in processing"; + $status = 0; + break; + case 551: $message = "User not local; please try forwarding"; + $status = 0; + break; + case 452: $message = "Requested action not taken: insufficient system storage"; + $status = 0; + break; + case 552: $message = "Requested mail action aborted: exceeding storage allocation"; + $status = 0; + break; + case 553: $message = "Requested action not taken: mailbox name not allowed"; + $status = 0; + break; + case 354: $message = "Start mail input; end with ."; + $status = 5; + break; + case 554: $message = "Transaction failed"; + $status = 0; + break; + default: $message = "Unknown response: $line"; + $status = 0; + $error_num = "001"; + break; + } + + if ($status == 0) { + echo ""; + echo ""; + echo "
ERROR

"; + echo "   Error Number: $err_num
"; + echo "         Reason: $message
"; + echo "Server Response: $line
"; + echo "
MAIL NOT SENT"; + echo "
"; + exit; + } + return $err_num; + } ?> \ No newline at end of file diff --git a/src/login.php b/src/login.php index 7e0b4983..55259bf4 100644 --- a/src/login.php +++ b/src/login.php @@ -15,17 +15,17 @@ include("../config/config.php"); include("../functions/strings.php"); - echo "\n"; + echo "\n"; echo "
\n"; echo "
\n"; echo "
SquirrelMail version $version
By the SquirrelMail Development Team
\n"; echo "\n"; echo " \n"; - echo " \n"; echo " \n"; - echo "
\n"; + echo " \n"; echo "
$org_name Login
\n"; echo "
\n"; + echo " \n"; echo " \n"; echo " \n"; echo "
\n"; diff --git a/src/signout.php b/src/signout.php index 9439d60f..5c327e42 100644 --- a/src/signout.php +++ b/src/signout.php @@ -16,23 +16,20 @@ ?> \n"; - echo "

"; - echo " "; + echo "\n"; + echo "

"; + echo " "; echo " "; echo " "; - echo " "; + echo " "; echo " "; echo " "; - echo " "; + echo " "; echo " ";
"; echo " Sign Out"; echo "
"; echo "
You have been successfully signed out.
"; echo " Click here to log back in.

"; echo "
"; echo "
"; echo "