SenderMustExistInExternalDatabase

I am using 2-0-15 on RedHat 7.3 with LDAP. I have the following set in
config.pm:

$LookupSenderInExternalDatabase = 1;
$SenderMustExistInExternalDatabase = 1;
$WebExternalAuth = 1;

and set up the LookupExternalUserInfo subroutine.

I tested by sending a message and got a bounce saying ‘RT couldn’t find
requestor via its external database lookup’. However my user account was
automatically created and I can log in fine. I thought this was strange
and did some checking. bin/rt-mailgate says:

if ($RT::LookupSenderInExternalDatabase &&
$RT::SenderMustExistInExternalDatabase ) {

 MailError(To => $RT::OwnerEmail,
           Subject => "RT Bounce: $Subject",
           Explanation => "RT couldn't find requestor via its external 

database lookup",
MIMEObj => $entity);

}

This means I will get the bounce every time regardless of whether or not I
was found (if both variables are set to 1). I fixed this by changing the
if statement to:

if ($RT::LookupSenderInExternalDatabase &&
$RT::SenderMustExistInExternalDatabase &&
!$RT::Interface::email::FoundInExternalDatabase ) {

and added the following to lib/RT/Interfaces/Email.pm after line 361 (in
sub GetCurrentUser):

$RT::Interface::email::FoundInExternalDatabase =
$UserFoundInExternalDatabase;

I also added $FoundInExternalDatabase to @EXPORT_OK in Email.pm and to use
RT::Interface::Email qw() in rt-mailgate.

There may be a better way to do this, but this fix worked for me so I
thought I would share it. I probably won’t hang out long on the list
because of the traffic, but will check the archives.

Thanks,
Jeff Hoover