# since 1.5.2
$abook_file_line_length = 2048 if ( !$abook_file_line_length );
$config_location_base = '' if ( !$config_location_base );
+$smtp_sitewide_user = '' if ( !$smtp_sitewide_user );
+$smtp_sitewide_pass = '' if ( !$smtp_sitewide_pass );
if ( $ARGV[0] eq '--install-plugin' ) {
print "Activating plugin " . $ARGV[1] . "\n";
print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
print "5. SMTP Port : $WHT$smtpPort$NRM\n";
print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
- print "7. SMTP Authentication : $WHT$smtp_auth_mech$NRM\n";
+ print "7. SMTP Authentication : $WHT$smtp_auth_mech" . display_smtp_sitewide_userpass() ."$NRM\n";
print "8. Secure SMTP (TLS) : $WHT" . display_use_tls($use_smtp_tls) . "$NRM\n";
print "9. Header encryption key : $WHT$encode_header_key$NRM\n";
print "\n";
return $new_smtpPort;
}
-# authenticated server
-sub command18 {
- return;
- # This sub disabled by tassium - it has been replaced with smtp_auth_mech
- print "Do you wish to use an authenticated SMTP server? Your server must\n";
- print "support this in order for SquirrelMail to work with it. We implemented\n";
- print "it according to RFC 2554.\n";
-
- $YesNo = 'n';
- $YesNo = 'y' if ( lc($use_authenticated_smtp) eq 'true' );
-
- print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
-
- $new_use_authenticated_smtp = <STDIN>;
- $new_use_authenticated_smtp =~ tr/yn//cd;
- return 'true' if ( $new_use_authenticated_smtp eq "y" );
- return 'false' if ( $new_use_authenticated_smtp eq "n" );
- return $use_authenticated_smtp;
-}
-
# pop before SMTP
sub command18a {
print "Do you wish to use POP3 before SMTP? Your server must\n";
$inval=<STDIN>;
chomp($inval);
if ($inval =~ /^none\b/i) {
- # SMTP doesn't necessarily require logins
- return "none";
+ # remove sitewide smtp authentication information
+ $smtp_sitewide_user = '';
+ $smtp_sitewide_pass = '';
+ # SMTP doesn't necessarily require logins
+ return "none";
+ } elsif ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
+ ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
+ command_smtp_sitewide_userpass($inval);
+ return lc($inval);
+ } elsif (trim($inval) eq '') {
+ # user selected default value
+ command_smtp_sitewide_userpass($smtp_auth_mech);
+ return $smtp_auth_mech;
+ } else {
+ # user entered garbage
+ return $smtp_auth_mech;
}
- if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
- ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
- return lc($inval);
+}
+
+sub command_smtp_sitewide_userpass($) {
+ # get first function argument
+ my $auth_mech = shift(@_);
+ my $default, $tmp;
+ $auth_mech = lc(trim($auth_mech));
+ if ($auth_mech ne 'cram-md5' &&
+ $auth_mech ne 'digest-md5' &&
+ $auth_mech ne 'login' &&
+ $auth_mech ne 'plain') {
+ return;
+ }
+ print "SMTP authentication uses IMAP username and password by default.\n";
+ print "\n";
+ print "Would you like to use other login and password for all SquirrelMail \n";
+ print "SMTP connections?";
+ if ($smtp_sitewide_user ne '') {
+ $default = 'y';
+ print " [Yn]:";
+ } else {
+ $default = 'n';
+ print " [yN]:";
+ }
+ $tmp=<STDIN>;
+ $tmp = trim($tmp);
+
+ if ($tmp eq '') {
+ $tmp = $default;
} else {
- # user entered garbage, or default value so nothing needs to be set
- return $smtp_auth_mech;
+ $tmp = lc($tmp);
+ }
+
+ if ($tmp eq 'n') {
+ $smtp_sitewide_user = '';
+ $smtp_sitewide_pass = '';
+ } elsif ($tmp eq 'y') {
+ print "Enter username [$smtp_sitewide_user]:";
+ my $new_user = <STDIN>;
+ $new_user = trim($new_user);
+ if ($new_user ne '') {
+ $smtp_sitewide_user = $new_user;
+ }
+ if ($smtp_sitewide_user ne '') {
+ print "If you don't enter any password, current sitewide password will be used.\n";
+ print "If you enter space, password will be set to empty string.\n";
+ print "Enter password:";
+ my $new_pass = <STDIN>;
+ if ($new_pass ne "\n") {
+ $smtp_sitewide_pass = trim($new_pass);
+ }
+ } else {
+ print "Invalid input. You must set username used for SMTP authentication.\n";
+ print "Click any key to continue\n";
+ $tmp = <STDIN>;
+ }
+ } else {
+ print "Invalid input\n";
+ print "Click any key to continue\n";
+ $tmp = <STDIN>;
}
}
+# Sub adds information about SMTP authentication type to menu
+sub display_smtp_sitewide_userpass() {
+ my $ret = '';
+ if ($smtp_auth_mech ne 'none') {
+ if ($smtp_sitewide_user ne '') {
+ $ret = ' (with custom username and password)';
+ } else {
+ $ret = ' (with IMAP username and password)';
+ }
+ }
+ return $ret;
+}
+
# TLS
# This sub is reused for IMAP and SMTP
# Args: service name, default value
# string
print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
+ print CF "\$smtp_sitewide_user = '". quote_single($smtp_sitewide_user) ."';\n";
+ print CF "\$smtp_sitewide_pass = '". quote_single($smtp_sitewide_pass) ."';\n";
# string
print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
# boolean
return 1;
}
}
+
+# quotes string written in single quotes
+sub quote_single($) {
+ my $string = shift(@_);
+ $string =~ s/\'/\\'/g;
+ return $string;
+}
OPTIONAL SMTP AUTH CONFIGURATION
--------------------------------
-If you need all users to send mail via an upstream SMTP provider
-(your ISP, for example), and that ISP requires authentication,
-there are two variables that can be added to config_local.php
-that will specify a sitewide SMTP username and password.
-
-Set up SMTP authentication to the remote server according to the
-instructions above, then add the following to config_local.php,
-replacing <smtp_user> and <smtp_pass> with the username and password
-you'd like to use for the entire site:
-
- $smtp_sitewide_user = '<smtp_user>';
- $smtp_sitewide_pass = '<smtp_pass>';
-
-These values will be used to connect to the SMTP server as long
-as the authentication mechanism is something besides 'none', i.e.
-'login','plain','cram-md5', or 'digest-md5'.
+In SMTP authentication SquirrelMail uses user's login name and password. If you
+need all users to send mail via an upstream SMTP provider (your ISP, for
+example), and that ISP requires authentication, you can configure custom
+username and password. $smtp_sitewide_user configuration variable stores custom
+username used during SMTP authentication. $smtp_sitewide_pass stores custom
+password that is used during SMTP authentication, if $smtp_sitewide_user
+variable is not empty.
+
+SquirrelMail 1.5.0 and 1.5.1 stored these configuration variables in
+config_local.php. Newer SquirrelMail versions allow to configure them in conf.pl
+configuration utility.
+
+These configuration variables will be used to connect to the SMTP server as long
+as the authentication mechanism is something besides 'none', i.e. 'login',
+'plain', 'cram-md5', or 'digest-md5'.
DEBUGGING SSL ERROR MESSAGES
----------------------------
* SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL
routines:func(148):reason(1040) in some script.
- Error generated by SSL libraries. Locate numbers listed 'SSL
+ Error generated by SSL library. Locate numbers listed in 'SSL
routines:func(###):reason(####)' string, find ssl.h file in your OpenSSL
sources and locate same numbers listed in '/* Error codes for the SSL
functions. */' section. Error define can be self explanatory. If you don't