Added support for POP before SMTP - note: I haven't actually tested this
authorbrong <brong@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 3 Apr 2002 09:38:43 +0000 (09:38 +0000)
committerbrong <brong@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 3 Apr 2002 09:38:43 +0000 (09:38 +0000)
against a real POP before SMTP server - just locally against a POP server
to make sure it was doing the check.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2673 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
config/conf.pl
functions/smtp.php

index 4188eee04cc27a7edadb7fdc34cb1eae92595b76..e4b8c2780d02b427e49459e63dbf8d87b528bbc3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 
 Version 1.2.6 -- CVS
 --------------------
+  - Added POP3 Before SMTP option (feature request: #498428)
   - Added a server-side thread sorting option per folder
   - Added a server-side sorting global option
   - Fix for jumping buttons in Mozilla (bug #522149)
index 76159a7e001263fbce7619fbedb138c3527f5c85..0d768208e953f28545b3cd281f1c2224eac6cba5 100755 (executable)
@@ -378,10 +378,11 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             print "6.    SMTP Server        : $WHT$smtpServerAddress$NRM\n";
             print "7.    SMTP Port          : $WHT$smtpPort$NRM\n";
             print "8.    Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
+            print "9.    POP Before SMTP    : $WHT$pop_before_smtp$NRM\n";
         }
-        print "9.  Server               : $WHT$imap_server_type$NRM\n";
-        print "10. Invert Time          : $WHT$invert_time$NRM\n";
-        print "11. Delimiter            : $WHT$optional_delimiter$NRM\n";
+        print "10.  Server               : $WHT$imap_server_type$NRM\n";
+        print "11. Invert Time          : $WHT$invert_time$NRM\n";
+        print "12. Delimiter            : $WHT$optional_delimiter$NRM\n";
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 3 ) {
@@ -567,9 +568,10 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 6 )  { $smtpServerAddress      = command16(); }
             elsif ( $command == 7 )  { $smtpPort               = command17(); }
             elsif ( $command == 8 )  { $use_authenticated_smtp = command18(); }
-            elsif ( $command == 9 )  { $imap_server_type       = command19(); }
-            elsif ( $command == 10 ) { $invert_time            = command110(); }
-            elsif ( $command == 11 ) { $optional_delimiter     = command111(); }
+            elsif ( $command == 9 )  { $pop_before_smtp        = command18a(); }
+            elsif ( $command == 10 ) { $imap_server_type       = command19(); }
+            elsif ( $command == 11 ) { $invert_time            = command110(); }
+            elsif ( $command == 12 ) { $optional_delimiter     = command111(); }
         } elsif ( $menu == 3 ) {
             if    ( $command == 1 )  { $default_folder_prefix          = command21(); }
             elsif ( $command == 2 )  { $show_prefix_option             = command22(); }
@@ -881,6 +883,23 @@ sub command18 {
     return $use_authenticated_smtp;
 }
 
+# pop before SMTP
+sub command18a {
+    print "Do you wish to use POP3 before SMTP?  Your server must\n";
+    print "support this in order for SquirrelMail to work with it.\n";
+
+    $YesNo = 'n';
+    $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" );
+
+    print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
+
+    $new_pop_before_smtp = <STDIN>;
+    $new_pop_before_smtp =~ tr/yn//cd;
+    return "true"  if ( $new_pop_before_smtp eq "y" );
+    return "false"  if ( $new_pop_before_smtp eq "n" );
+    return $pop_before_smtp;
+}
+
 # imap_server_type 
 sub command19 {
     print "Each IMAP server has its own quirks.  As much as we tried to stick\n";
@@ -2208,6 +2227,7 @@ sub save_data {
         print CF "\$smtpPort               = $smtpPort;\n";
         print CF "\$sendmail_path          = '$sendmail_path';\n";
         print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
+        print CF "\$pop_before_smtp        = $pop_before_smtp;\n";
         print CF "\$imap_server_type       = '$imap_server_type';\n";
         print CF "\$invert_time            = $invert_time;\n";
         print CF "\$optional_delimiter     = '$optional_delimiter';\n";
index 100be5e209ebe98cf670df87c7f76a7c6c02823d..122ab7e49503529623e0f03b2066f944799098c2 100644 (file)
@@ -511,6 +511,39 @@ function sendSMTP($t, $c, $b, $subject, $body, $more_headers, $session) {
     if (!$from_addr) {
         $from_addr = "$popuser@$domain";
     }
+
+    /* POP3 BEFORE SMTP CODE HERE */
+    global $pop_before_smtp;
+    if (isset($pop_before_smtp) && $pop_before_smtp === true) {
+        if (!isset($pop_port)) {
+            $pop_port = 110;
+        }
+        if (!isset($pop_server)) {
+            $pop_server = $smtpServerAddress; /* usually the same host! */
+        }
+        $popConnection = fsockopen($pop_server, $pop_port, $err_no, $err_str);
+        if (!$popConnection) {
+            error_log("Error connecting to POP Server ($pop_server:$pop_port)"
+                  . " $err_no : $err_str");
+        } else {
+            $tmp = fgets($popConnection, 1024); /* banner */
+            if (!eregi("^\+OK", $tmp, $regs)) {
+                return(0);
+            }
+            fputs($popConnection, "USER $username\r\n");
+            $tmp = fgets($popConnection, 1024);
+            if (!eregi("^\+OK", $tmp, $regs)) {
+                return(0);
+            }
+            fputs($popConnection, 'PASS ' . OneTimePadDecrypt($key, $onetimepad) . "\r\n");
+            $tmp = fgets($popConnection, 1024);
+            if (!eregi("^\+OK", $tmp, $regs)) {
+                return(0);
+            }
+            fputs($popConnection, "QUIT\r\n"); /* log off */
+            fclose($popConnection);
+        }
+    }
     
     $smtpConnection = fsockopen($smtpServerAddress, $smtpPort, 
                                 $errorNumber, $errorString);
@@ -751,7 +784,7 @@ function calculate_references($refs, $inreplyto, $old_reply_to) {
         }
         else {
             $refer .= $inreplyto;
-        }                      
+        }                        
     }
     trim($refer);
     $refer = str_replace(' ', "$rn        ", $refer);
@@ -789,7 +822,7 @@ function sendMessage($t, $c, $b, $subject, $body, $reply_id, $MDN,
         if(strlen($hdr->message_id) > 2) {
             $refs = get_reference_header ($imap_stream, $reply_id);
             $inreplyto = $hdr->message_id;
-                       $old_reply_to = $hdr->inrepto;
+            $old_reply_to = $hdr->inrepto;
             $refer = calculate_references ($refs, $inreplyto, $old_reply_to);
             $more_headers['In-Reply-To'] = $inreplyto;
             $more_headers['References']  = $refer;