changeset 434:375518f786db

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 10 Sep 2008 21:27:57 +0400
parents 2b6aba7fe8b5
children e2df123bbbe2
files src/mail/ngx_mail_proxy_module.c
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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;
             }