Gmail SMTP typo in password is not handled gracefully

Fejes József <[email protected]> Tue, 9 Jan 2018 21:58:25 +0100
Newsgroups gmane.mail.nullmailer
Message-ID <CALU-w98nbSuGhSCQQw-1PfRt+09D5e-HEKeR6m6kPgJKz5cTQw@mail.gmail.com>
Hi,

I've just installed nullmailer on my Debian system. I configured Gmail
SMTP as my remote. I made a typo in the password and it caused a lot
of trouble.

Here's my configuration:
- adminaddr: [email protected]
- defaultdomain: hp.home.joco.name
- remotes: smtp.gmail.com smtp port=587 starttls
[email protected] pass=password

Gmail uses the authenticated email as sender, and I configured that as
the recipient as well. This is intended, I want to see both sent and
received emails in the same place.

With the correct password, I can do `sendmail root`, the email is sent
and I can see it in Gmail, great.

With a typo in the password, this is the series of events:
- Gmail responds with 535
- nullmailer thinks this is a permanent error
- nullmailer moves the message to failed (it looks clean), and
generates a bounce
- nullmailer tries to send the bounce through Gmail, which of course
still doesn't work, we have an infinite loop here, the failed
directory keeps growing indefinitely
- some of the mails in failed have a To of <>, some have <#@[]>
- actually it doesn't retry indefinitely, Gmail locks out the account
because of too many attempts, which is even worse

So I think there are several things which could go better:
- an authentication problem should be handled as transient, and
retried with a delay to avoid lockout
- nullmailer should detect when it's generating the bounce of a bounce
recursively and stop, possibly by ignoring adminaddr and delivering
locally
- the address of the bounces becomes garbage at some point, not sure why

Let me know if you need any more information (or even code contributions).

Cheers,
Jozsef