# HG changeset patch # User Maxim Dounin # Date 1221067677 -14400 # Node ID 375518f786dbda2710c371fc6d1618a079f0d0b0 # Parent 2b6aba7fe8b52869293f7cd3a7167686e60ab1ad Mail: don't drop connection when RCPT TO fails. Always pass reply for RCPT TO back to client and establish proxied connection. There is no real reason to close connection here. diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c --- a/src/mail/ngx_mail_proxy_module.c +++ b/src/mail/ngx_mail_proxy_module.c @@ -104,8 +104,7 @@ ngx_module_t ngx_mail_proxy_module = { }; -static u_char smtp_auth_ok[] = "235 2.0.0 OK" CRLF; -static u_char smtp_ok[] = "250 2.0.0 OK" CRLF; +static u_char smtp_ok[] = "235 2.0.0 OK" CRLF; void @@ -603,18 +602,14 @@ ngx_mail_proxy_smtp_handler(ngx_event_t case ngx_smtp_xclient: case ngx_smtp_to: - if (s->auth_method == NGX_MAIL_AUTH_NONE) { - ngx_memcpy(s->proxy->buffer->start, smtp_ok, sizeof(smtp_ok) - 1); + if (s->auth_method != NGX_MAIL_AUTH_NONE) { + ngx_memcpy(s->proxy->buffer->start, smtp_ok, + sizeof(smtp_ok) - 1); s->proxy->buffer->last = s->proxy->buffer->start + sizeof(smtp_ok) - 1; - } else { - ngx_memcpy(s->proxy->buffer->start, smtp_auth_ok, - sizeof(smtp_auth_ok) - 1); - s->proxy->buffer->last = s->proxy->buffer->start - + sizeof(smtp_auth_ok) - 1; + s->proxy->buffer->pos = s->proxy->buffer->start; } - s->proxy->buffer->pos = s->proxy->buffer->start; s->connection->read->handler = ngx_mail_proxy_handler; s->connection->write->handler = ngx_mail_proxy_handler; @@ -753,11 +748,13 @@ ngx_mail_proxy_read_response(ngx_mail_se default: /* NGX_MAIL_SMTP_PROTOCOL */ switch (state) { + case ngx_smtp_to: + return NGX_OK; + case ngx_smtp_helo: case ngx_smtp_helo_from: case ngx_smtp_helo_xclient: case ngx_smtp_from: - case ngx_smtp_to: if (p[0] == '2' && p[1] == '5' && p[2] == '0') { return NGX_OK; }