Lamson/Salmon puts mails into undeliverable queue if no handler matches. However, I can't do this matching entirely using regex for the route decorator, because I need to validate the address using information from, for instance, a database. Thus, I need to be able to put mail with invalid address into the undeliverable queue from the handler. How can I do this?
My handler looks something like:
@route("(address)@(host)", address=".+", host="example\.com")
@stateless
def START(message, address=None, host=None):
# Here is a complex validation of the address.
# It uses, for instance, information from a database.
# If the address is valid, mail is sent and the function returns
# The code ends up here if the address wasn't valid.
# How can I put the mail into the undelivarable queue?