From 2044f95a9a51cd0ad1b75b3a2b811e94bcf1f49f Mon Sep 17 00:00:00 2001 From: brong Date: Wed, 3 Apr 2002 09:38:43 +0000 Subject: [PATCH] Added support for POP before SMTP - note: I haven't actually tested this 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 | 1 + config/conf.pl | 32 ++++++++++++++++++++++++++------ functions/smtp.php | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4188eee0..e4b8c278 100644 --- 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) diff --git a/config/conf.pl b/config/conf.pl index 76159a7e..0d768208 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -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 = ; + $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"; diff --git a/functions/smtp.php b/functions/smtp.php index 100be5e2..122ab7e4 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -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; -- 2.25.1