comparison src/mail/ngx_mail.h @ 400:f1e2fab7a46c

Mail: smtp proxy without authentication. Activated by auth method "unauth" in smtp_auth directive. Waits for MAIL FROM and first RCPT TO from client, asks auth_http for backend with additional headers Auth-SMTP-Helo, Auth-SMTP-From, Auth-SMTP-To, and establishes connection to backend. Auth-SMTP-From/To currently contain full command (e.g. "mail from: <>"), this may change in future. The functionality was designed to take off load from real smtp servers. Additionally it may be used to implement pop-before-smtp authentication (but dont do it unless you really need it - use real auth instead). Current bug-features: - If only "unauth" method activated in config, other methods (e.g. plain, login) not advertised but accepted. Make sure your auth server handles this gracefully. - If backend server returns error on MAIL FROM / RCPT TO command while proxy tunnel setup, nginx will close connection to client with 4xx error. One may use proxy_pass_error_message directive to pass original error message to client. - Syntax of MAIL FROM / RCPT TO commands from client isn't checked.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 22 Jul 2007 23:55:12 +0000
parents f9e6413396d4
children d4cac61d8e95
comparison
equal deleted inserted replaced
399:137505db4246 400:f1e2fab7a46c
179 ngx_smtp_auth_login_username, 179 ngx_smtp_auth_login_username,
180 ngx_smtp_auth_login_password, 180 ngx_smtp_auth_login_password,
181 ngx_smtp_auth_plain, 181 ngx_smtp_auth_plain,
182 ngx_smtp_auth_cram_md5, 182 ngx_smtp_auth_cram_md5,
183 ngx_smtp_helo, 183 ngx_smtp_helo,
184 ngx_smtp_noxclient, 184 ngx_smtp_helo_xclient,
185 ngx_smtp_xclient 185 ngx_smtp_helo_from,
186 ngx_smtp_xclient,
187 ngx_smtp_xclient_from,
188 ngx_smtp_from,
189 ngx_smtp_to
186 } ngx_smtp_state_e; 190 } ngx_smtp_state_e;
187 191
188 192
189 typedef struct { 193 typedef struct {
190 ngx_peer_connection_t upstream; 194 ngx_peer_connection_t upstream;
214 unsigned quoted:1; 218 unsigned quoted:1;
215 unsigned backslash:1; 219 unsigned backslash:1;
216 unsigned no_sync_literal:1; 220 unsigned no_sync_literal:1;
217 unsigned starttls:1; 221 unsigned starttls:1;
218 unsigned esmtp:1; 222 unsigned esmtp:1;
219 unsigned auth_method:2; 223 unsigned auth_method:3;
220 unsigned auth_wait:1; 224 unsigned auth_wait:1;
221 225
222 ngx_str_t login; 226 ngx_str_t login;
223 ngx_str_t passwd; 227 ngx_str_t passwd;
224 228
226 ngx_str_t tag; 230 ngx_str_t tag;
227 ngx_str_t tagged_line; 231 ngx_str_t tagged_line;
228 232
229 ngx_str_t *addr_text; 233 ngx_str_t *addr_text;
230 ngx_str_t smtp_helo; 234 ngx_str_t smtp_helo;
235 ngx_str_t smtp_from;
236 ngx_str_t smtp_to;
231 237
232 ngx_uint_t command; 238 ngx_uint_t command;
233 ngx_array_t args; 239 ngx_array_t args;
234 240
235 ngx_uint_t login_attempt; 241 ngx_uint_t login_attempt;
295 301
296 #define NGX_MAIL_AUTH_PLAIN 0 302 #define NGX_MAIL_AUTH_PLAIN 0
297 #define NGX_MAIL_AUTH_LOGIN 1 303 #define NGX_MAIL_AUTH_LOGIN 1
298 #define NGX_MAIL_AUTH_APOP 2 304 #define NGX_MAIL_AUTH_APOP 2
299 #define NGX_MAIL_AUTH_CRAM_MD5 3 305 #define NGX_MAIL_AUTH_CRAM_MD5 3
306 #define NGX_MAIL_AUTH_UNAUTH 4
300 307
301 308
302 #define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002 309 #define NGX_MAIL_AUTH_PLAIN_ENABLED 0x0002
303 #define NGX_MAIL_AUTH_LOGIN_ENABLED 0x0004 310 #define NGX_MAIL_AUTH_LOGIN_ENABLED 0x0004
304 #define NGX_MAIL_AUTH_APOP_ENABLED 0x0008 311 #define NGX_MAIL_AUTH_APOP_ENABLED 0x0008
305 #define NGX_MAIL_AUTH_CRAM_MD5_ENABLED 0x0010 312 #define NGX_MAIL_AUTH_CRAM_MD5_ENABLED 0x0010
313 #define NGX_MAIL_AUTH_UNAUTH_ENABLED 0x0020
306 314
307 315
308 #define NGX_MAIL_PARSE_INVALID_COMMAND 20 316 #define NGX_MAIL_PARSE_INVALID_COMMAND 20
309 317
310 318