qmail-inject: do not parse header recipients if "-a" is given #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
qmail-inject can parse the message header to determine the recipients of a mail. You can also pass it a list of recipients on command line so it will ignore the recipients stated in the header. This is e.g. used when you redirect a mail by a .qmail file. But even if those recipients will not be used the header fields will still be parsed and a bounce is generated on failure.
If a mail is injected from network with the broken header field
To: foo: bar, baz
then this would be delivered fine as the recipient is given in the SMTP transmission. If it could not be directly delivered but is forwarded to another user by a .qmail file or a virtualdomain alias then this mail is passed through "qmail-inject -a newrecipient". Nevertheless the header fields are parsed, the error is raised and the message is bounced. This leads to ugly bounces with the message "qmail-inject: fatal: unable to parse this line:". Since the message is of course spam the bounce will bounce again and annoy the postmaster. This patch changes qmail-inject to totally ignore the lines with recipients (To:, Cc:, Bcc) if the recipients were passed as arguments. In this case the mail will be routed to the original recipient and can there be handled.