Commit d0cca271 d0cca27175be68c4d75c79b0d5c5aca7e8251c5b by Sergey Poznyakoff

Control the value

of READ_RECIPIENTS property to decide whether the message
should be scanned for recipient addresses.
1 parent 40caf9c3
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 {
230 argc++; /* -t */ 241 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,6 +915,15 @@ smtp_address_add (address_t *paddr, const char *value) ...@@ -915,6 +915,15 @@ 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;
...@@ -939,6 +948,8 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) ...@@ -939,6 +948,8 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
939 return status; 948 return status;
940 } 949 }
941 950
951 if (!to || _smtp_property_is_set (smtp, "READ_RECIPIENTS"))
952 {
942 if ((status = message_get_header (msg, &header))) 953 if ((status = message_get_header (msg, &header)))
943 return status; 954 return status;
944 955
...@@ -949,7 +960,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) ...@@ -949,7 +960,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
949 smtp_address_add (&smtp->rcpt_to, value); 960 smtp_address_add (&smtp->rcpt_to, value);
950 free (value); 961 free (value);
951 } 962 }
952 else if (status && status != ENOENT) 963 else if (status != ENOENT)
953 goto end; 964 goto end;
954 965
955 status = header_aget_value (header, MU_HEADER_CC, &value); 966 status = header_aget_value (header, MU_HEADER_CC, &value);
...@@ -959,7 +970,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) ...@@ -959,7 +970,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
959 smtp_address_add (&smtp->rcpt_to, value); 970 smtp_address_add (&smtp->rcpt_to, value);
960 free (value); 971 free (value);
961 } 972 }
962 else if (status && status != ENOENT) 973 else if (status != ENOENT)
963 goto end; 974 goto end;
964 975
965 status = header_aget_value (header, MU_HEADER_BCC, &value); 976 status = header_aget_value (header, MU_HEADER_BCC, &value);
...@@ -968,7 +979,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) ...@@ -968,7 +979,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
968 smtp_address_add (&smtp->rcpt_bcc, value); 979 smtp_address_add (&smtp->rcpt_bcc, value);
969 free (value); 980 free (value);
970 } 981 }
971 else if (status && status != ENOENT) 982 else if (status != ENOENT)
972 goto end; 983 goto end;
973 984
974 /* If to or bcc is present, the must be OK. */ 985 /* If to or bcc is present, the must be OK. */
...@@ -977,6 +988,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to) ...@@ -977,6 +988,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
977 988
978 if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc))) 989 if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc)))
979 goto end; 990 goto end;
991 }
980 992
981 end: 993 end:
982 994
......