foxcpp / maddy

✉️ Composable all-in-one mail server.
https://maddy.email
GNU General Public License v3.0
5.04k stars 241 forks source link

Bug: Error raised on bounce deliver_to &outbound_delivery #711

Open qjebbs opened 3 months ago

qjebbs commented 3 months ago

Describe the bug

What do you think is wrong?

The config:

remote_queue.bounce.deliver_to &outbound_delivery

leads to error

SMTPUTF8 is unsupported, cannot convert sender address

Background: I use Maddy as a side submission service, I want to deliver DSN to remote main service instead of local

Steps to reproduce

  1. Change the default config file:

    target.queue remote_queue {
        target &outbound_delivery
    
        autogenerated_msg_domain $(primary_domain)
        bounce {
            destination $(local_domains) {
    -            deliver_to &local_routing
    +            deliver_to &outbound_delivery
            }
            default_destination {
                reject 550 5.0.0 "Refusing to send DSNs to non-local addresses"
            }
        }
    }
  2. Submit an email with invalid RCPT invalid@example.org to submission tls://0.0.0.0:465

  3. DSN delivery reports error

Log files

queue: delivery attempt failed  {"msg_id":"74303153","rcpt":"invalid@example.org","reason":"Domain does not accept email (null MX)","smtp_code":556,"smtp_enchcode":"5.1.10","smtp_msg":"Domain does not accept email (null MX)"}
queue: not delivered, permanent error   {"msg_id":"74303153","rcpt":"invalid@example.org"}
queue: generated failed DSN {"dsn_id":"44714bcf","msg_id":"74303153"}
queue: failed to enqueue DSN    {"dsn_id":"9ffc9be2","effective_rcpt":"xxx@xxxx.com","msg_id":"3a4d2026","reason":"address: missing at-sign","remote_server":"xxxx.com.","smtp_code":550,"smtp_enchcode":"5.6.7","smtp_msg":"SMTPUTF8 is unsupported, cannot convert sender address"}

Environment information

Did some debugging:

dsnPipeline started with empty RCPT.

https://github.com/foxcpp/maddy/blob/1d6cd8c35f4c4a1279084ae974ecfcf73a426743/internal/target/queue/queue.go#L961

The error is caused by address.ToASCII(from) with from being empty:

https://github.com/foxcpp/maddy/blob/1d6cd8c35f4c4a1279084ae974ecfcf73a426743/internal/smtpconn/smtpconn.go#L309-L327

The message is misleading, and the expected actions cannot be done.