diff -Nur --no-dereference qpsmtpd-0.96.old/plugins/auth/auth_imap qpsmtpd-0.96/plugins/auth/auth_imap --- qpsmtpd-0.96.old/plugins/auth/auth_imap 2016-02-16 17:52:02.000000000 -0500 +++ qpsmtpd-0.96/plugins/auth/auth_imap 2023-12-18 12:14:23.581000000 -0500 @@ -25,17 +25,30 @@ relay or a primary mail server. The principal benefit is ease of adminstration when an existing IMAP service is already established. -head1 AUTHOR Christopher Heschong +=head1 AUTHOR Christopher Heschong Edits to add SSL support and updated for latest qpsmtpd version - James Turnbull =head1 COPYRIGHT AND LICENSE Copyright (c) 2004 Christopher Heschong This plugin is licensed under the same terms as the qpsmtpd package itself. Please see the LICENSE file included with qpsmtpd for details. + +=head1 SYNOPSIS + +In config/plugins: + + auth/auth_imap \ + enable_smtp no \ + enable_ssmtp yes =cut use Net::IMAP::Simple; +use Qpsmtpd::Constants; + +use Socket; +use constant SMTP_PORT => getservbyname("smtp", "tcp") || 25; +use constant SSMTP_PORT => getservbyname("ssmtp", "tcp") || 465; sub register { my ($self, $qp, @args) = @_; @@ -51,16 +64,35 @@ if (@args > 1 and $args[1] =~ /^(\d+)$/) { $self->{_imap_port} = $1; } + if (@args > 2 and ($args[3] eq "enable_smtp" ) ) { + $self->{_enable_smtp}= $args[4] || 'no'; + } + if (@args > 4 and ( $args[5] eq "enable_ssmtp" )) { + $self->{_enable_ssmtp} = $args[6] || 'yes'; + } $self->log(LOGWARN, "WARNING: Ignoring additional arguments.") - if (@args > 2); + if (@args > 6); } else { die("No IMAP server specified in plugins file."); } # set any values that are not already - $self->{_imap_server} ||= "127.0.0.1"; - $self->{_imap_port} ||= 143; + $self->{_imap_server} ||= "127.0.0.1"; + $self->{_imap_port} ||= 143; + $self->{_enable_smtp} ||= 'no'; + $self->{_enable_ssmtp} ||= 'yes'; + + my $port = $ENV{PORT} || SMTP_PORT; + + if ($self->{_enable_smtp} ne 'yes' && ($port == SMTP_PORT || $port == 587)) { + $self->log(LOGDEBUG, "skip: enable_smtp=no"); + return 0; + } + if ($port == SSMTP_PORT && $self->{_enable_ssmtp} ne 'yes') { + $self->log(LOGDEBUG, "skip: enable_ssmtp=no"); + return 0; + }; $self->register_hook("auth-login", "auth_imap"); $self->register_hook("auth-plain", "auth_imap");