Control the value
of READ_RECIPIENTS property to decide whether the message should be scanned for recipient addresses.
Showing
2 changed files
with
63 additions
and
40 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -166,6 +166,16 @@ sendmail_close (mailer_t mailer) | ... | @@ -166,6 +166,16 @@ sendmail_close (mailer_t mailer) |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | static int | ||
170 | mailer_property_is_set (mailer_t mailer, const char *name) | ||
171 | { | ||
172 | property_t property = NULL; | ||
173 | |||
174 | mailer_get_property (mailer, &property); | ||
175 | return property_is_set (property, name); | ||
176 | } | ||
177 | |||
178 | |||
169 | /* Close FD unless it is part of pipe P */ | 179 | /* Close FD unless it is part of pipe P */ |
170 | #define SCLOSE(fd,p) if (p[0]!=fd&&p[1]!=fd) close(fd) | 180 | #define SCLOSE(fd,p) if (p[0]!=fd&&p[1]!=fd) close(fd) |
171 | 181 | ||
... | @@ -195,7 +205,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, | ... | @@ -195,7 +205,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, |
195 | 205 | ||
196 | argc++; /* terminating NULL */ | 206 | argc++; /* terminating NULL */ |
197 | argc++; /* sendmail */ | 207 | argc++; /* sendmail */ |
198 | argc++; /* -oi (do not treat '.' as message terminator) */ | 208 | argc++; /* -oi (do not treat '.' as message |
209 | terminator) */ | ||
199 | 210 | ||
200 | if (from) | 211 | if (from) |
201 | { | 212 | { |
... | @@ -216,6 +227,7 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, | ... | @@ -216,6 +227,7 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, |
216 | 227 | ||
217 | argc += 2; /* -f from */ | 228 | argc += 2; /* -f from */ |
218 | } | 229 | } |
230 | |||
219 | if (to) | 231 | if (to) |
220 | { | 232 | { |
221 | status = address_get_email_count (to, &tocount); | 233 | status = address_get_email_count (to, &tocount); |
... | @@ -225,10 +237,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, | ... | @@ -225,10 +237,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, |
225 | 237 | ||
226 | argc += tocount; /* 1 per to address */ | 238 | argc += tocount; /* 1 per to address */ |
227 | } | 239 | } |
228 | else | 240 | |
229 | { | 241 | argc++; /* -t */ |
230 | argc++; /* -t */ | ||
231 | } | ||
232 | 242 | ||
233 | /* Allocate arg vec: */ | 243 | /* Allocate arg vec: */ |
234 | if ((argvec = calloc (argc, sizeof (*argvec))) == 0) | 244 | if ((argvec = calloc (argc, sizeof (*argvec))) == 0) |
... | @@ -259,7 +269,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, | ... | @@ -259,7 +269,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from, |
259 | } | 269 | } |
260 | argvec[argc++] = emailfrom; | 270 | argvec[argc++] = emailfrom; |
261 | } | 271 | } |
262 | if (!to) | 272 | |
273 | if (!to || mailer_property_is_set (mailer, "READ_RECIPIENTS")) | ||
263 | { | 274 | { |
264 | if ((argvec[argc++] = strdup ("-t")) == 0) | 275 | if ((argvec[argc++] = strdup ("-t")) == 0) |
265 | { | 276 | { | ... | ... |
... | @@ -915,12 +915,21 @@ smtp_address_add (address_t *paddr, const char *value) | ... | @@ -915,12 +915,21 @@ smtp_address_add (address_t *paddr, const char *value) |
915 | } | 915 | } |
916 | 916 | ||
917 | static int | 917 | static int |
918 | _smtp_property_is_set (smtp_t smtp, const char *name) | ||
919 | { | ||
920 | property_t property = NULL; | ||
921 | |||
922 | mailer_get_property (smtp->mailer, &property); | ||
923 | return property_is_set (property, name); | ||
924 | } | ||
925 | |||
926 | static int | ||
918 | _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) | 927 | _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) |
919 | { | 928 | { |
920 | int status = 0; | 929 | int status = 0; |
921 | header_t header = NULL; | 930 | header_t header = NULL; |
922 | char *value; | 931 | char *value; |
923 | 932 | ||
924 | /* Get RCPT_TO from TO, or the message. */ | 933 | /* Get RCPT_TO from TO, or the message. */ |
925 | 934 | ||
926 | if (to) | 935 | if (to) |
... | @@ -939,45 +948,48 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) | ... | @@ -939,45 +948,48 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) |
939 | return status; | 948 | return status; |
940 | } | 949 | } |
941 | 950 | ||
942 | if ((status = message_get_header (msg, &header))) | 951 | if (!to || _smtp_property_is_set (smtp, "READ_RECIPIENTS")) |
943 | return status; | ||
944 | |||
945 | status = header_aget_value (header, MU_HEADER_TO, &value); | ||
946 | |||
947 | if (status == 0) | ||
948 | { | 952 | { |
949 | smtp_address_add (&smtp->rcpt_to, value); | 953 | if ((status = message_get_header (msg, &header))) |
950 | free (value); | 954 | return status; |
951 | } | ||
952 | else if (status && status != ENOENT) | ||
953 | goto end; | ||
954 | 955 | ||
955 | status = header_aget_value (header, MU_HEADER_CC, &value); | 956 | status = header_aget_value (header, MU_HEADER_TO, &value); |
956 | 957 | ||
957 | if (status == 0) | 958 | if (status == 0) |
958 | { | 959 | { |
959 | smtp_address_add (&smtp->rcpt_to, value); | 960 | smtp_address_add (&smtp->rcpt_to, value); |
960 | free (value); | 961 | free (value); |
961 | } | 962 | } |
962 | else if (status && status != ENOENT) | 963 | else if (status != ENOENT) |
963 | goto end; | 964 | goto end; |
964 | 965 | ||
965 | status = header_aget_value (header, MU_HEADER_BCC, &value); | 966 | status = header_aget_value (header, MU_HEADER_CC, &value); |
966 | if (status == 0) | 967 | |
967 | { | 968 | if (status == 0) |
968 | smtp_address_add (&smtp->rcpt_bcc, value); | 969 | { |
969 | free (value); | 970 | smtp_address_add (&smtp->rcpt_to, value); |
970 | } | 971 | free (value); |
971 | else if (status && status != ENOENT) | 972 | } |
972 | goto end; | 973 | else if (status != ENOENT) |
974 | goto end; | ||
973 | 975 | ||
974 | /* If to or bcc is present, the must be OK. */ | 976 | status = header_aget_value (header, MU_HEADER_BCC, &value); |
975 | if (smtp->rcpt_to && (status = mailer_check_to (smtp->rcpt_to))) | 977 | if (status == 0) |
976 | goto end; | 978 | { |
979 | smtp_address_add (&smtp->rcpt_bcc, value); | ||
980 | free (value); | ||
981 | } | ||
982 | else if (status != ENOENT) | ||
983 | goto end; | ||
977 | 984 | ||
978 | if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc))) | 985 | /* If to or bcc is present, the must be OK. */ |
979 | goto end; | 986 | if (smtp->rcpt_to && (status = mailer_check_to (smtp->rcpt_to))) |
987 | goto end; | ||
980 | 988 | ||
989 | if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc))) | ||
990 | goto end; | ||
991 | } | ||
992 | |||
981 | end: | 993 | end: |
982 | 994 | ||
983 | if (status) | 995 | if (status) | ... | ... |
-
Please register or sign in to post a comment