Mercurial > masqmail-0.2
comparison src/smtp_out.c @ 171:349518b940db
added support for STARTTLS wrappers
added the route config option `instant_helo' which
causes masqmail, as SMTP client, not to wait for the
server's 220 greeting. Instead if says EHLO right at
once. You'll need this for STARTTLS wrappers that
usually eat the greeting line.
author | meillo@marmaro.de |
---|---|
date | Thu, 22 Jul 2010 23:30:05 +0200 |
parents | 52c82d755215 |
children | 087e99c7702a |
comparison
equal
deleted
inserted
replaced
170:0f0e4e7cd762 | 171:349518b940db |
---|---|
229 } | 229 } |
230 | 230 |
231 static gboolean | 231 static gboolean |
232 check_helo_response(smtp_base * psb) | 232 check_helo_response(smtp_base * psb) |
233 { | 233 { |
234 gchar *ptr = psb->buffer; | 234 gchar *ptr; |
235 | 235 |
236 if (!check_response(psb, FALSE)) | 236 if (!check_response(psb, FALSE)) |
237 return FALSE; | 237 return FALSE; |
238 | |
239 if (psb->last_code == 220) { | |
240 logwrite(LOG_NOTICE, "received a 220 greeting after sending EHLO,\n"); | |
241 logwrite(LOG_NOTICE, "please remove `instant_helo' from your route config\n"); | |
242 /* read the next response, cause that's the actual helo response */ | |
243 if (!read_response(psb, SMTP_CMD_TIMEOUT) || !check_response(psb, FALSE)) { | |
244 return FALSE; | |
245 } | |
246 } | |
247 | |
248 ptr = psb->buffer; | |
238 | 249 |
239 while (*ptr) { | 250 while (*ptr) { |
240 if (strncasecmp(&(ptr[4]), "SIZE", 4) == 0) { | 251 if (strncasecmp(&(ptr[4]), "SIZE", 4) == 0) { |
241 gchar *arg; | 252 gchar *arg; |
242 psb->use_size = TRUE; | 253 psb->use_size = TRUE; |
666 } | 677 } |
667 | 678 |
668 #endif | 679 #endif |
669 | 680 |
670 gboolean | 681 gboolean |
671 smtp_out_init(smtp_base * psb) | 682 smtp_out_init(smtp_base * psb, gboolean instant_helo) |
672 { | 683 { |
673 gboolean ok; | 684 gboolean ok; |
674 | 685 |
675 if ((ok = read_response(psb, SMTP_INITIAL_TIMEOUT))) { | 686 logwrite(LOG_INFO, "smtp_out_init(): instant_helo:%d\n", instant_helo); |
676 if ((ok = check_init_response(psb))) { | 687 |
677 | 688 if (instant_helo) { |
678 if ((ok = smtp_helo(psb, psb->helo_name))) { | 689 /* we say hello right away, hence we don't know if |
690 ESMTP is supported; we just assume it */ | |
691 psb->use_esmtp = 1; | |
692 } else { | |
693 if ((ok = read_response(psb, SMTP_INITIAL_TIMEOUT))) { | |
694 ok = check_init_response(psb); | |
695 } | |
696 if (!ok) { | |
697 smtp_out_log_failure(psb, NULL); | |
698 return ok; | |
699 } | |
700 } | |
701 | |
702 if ((ok = smtp_helo(psb, psb->helo_name))) { | |
679 #ifdef ENABLE_AUTH | 703 #ifdef ENABLE_AUTH |
680 if (psb->auth_name && psb->use_auth) { | 704 if (psb->auth_name && psb->use_auth) { |
681 /* we completely disregard the response of server here. If | 705 /* we completely disregard the response of server here. If |
682 authentication fails, the server will complain later | 706 authentication fails, the server will complain later |
683 anyway. I know, this is not polite... */ | 707 anyway. I know, this is not polite... */ |
684 smtp_out_auth(psb); | 708 smtp_out_auth(psb); |
685 } | 709 } |
686 #endif | 710 #endif |
687 } | |
688 } | |
689 } | 711 } |
690 if (!ok) | 712 if (!ok) |
691 smtp_out_log_failure(psb, NULL); | 713 smtp_out_log_failure(psb, NULL); |
692 return ok; | 714 return ok; |
693 } | 715 } |
897 return_path = msg->return_path; | 919 return_path = msg->return_path; |
898 | 920 |
899 if ((psb = smtp_out_open(host, port, resolve_list))) { | 921 if ((psb = smtp_out_open(host, port, resolve_list))) { |
900 set_heloname(psb, return_path->domain, TRUE); | 922 set_heloname(psb, return_path->domain, TRUE); |
901 /* initiate connection, send message and quit: */ | 923 /* initiate connection, send message and quit: */ |
902 if (smtp_out_init(psb)) { | 924 if (smtp_out_init(psb, FALSE)) { |
903 smtp_out_msg(psb, msg, return_path, rcpt_list, NULL); | 925 smtp_out_msg(psb, msg, return_path, rcpt_list, NULL); |
904 if (psb->error == smtp_ok || (psb->error == smtp_fail) || (psb->error == smtp_trylater) | 926 if (psb->error == smtp_ok || (psb->error == smtp_fail) || (psb->error == smtp_trylater) |
905 || (psb->error == smtp_syntax) || (psb->error == smtp_cancel)) | 927 || (psb->error == smtp_syntax) || (psb->error == smtp_cancel)) |
906 smtp_out_quit(psb); | 928 smtp_out_quit(psb); |
907 } | 929 } |