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
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -166,6 +166,16 @@ sendmail_close (mailer_t mailer)
return 0;
}
static int
mailer_property_is_set (mailer_t mailer, const char *name)
{
property_t property = NULL;
mailer_get_property (mailer, &property);
return property_is_set (property, name);
}
/* Close FD unless it is part of pipe P */
#define SCLOSE(fd,p) if (p[0]!=fd&&p[1]!=fd) close(fd)
......@@ -195,7 +205,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
argc++; /* terminating NULL */
argc++; /* sendmail */
argc++; /* -oi (do not treat '.' as message terminator) */
argc++; /* -oi (do not treat '.' as message
terminator) */
if (from)
{
......@@ -216,6 +227,7 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
argc += 2; /* -f from */
}
if (to)
{
status = address_get_email_count (to, &tocount);
......@@ -225,10 +237,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
argc += tocount; /* 1 per to address */
}
else
{
argc++; /* -t */
}
/* Allocate arg vec: */
if ((argvec = calloc (argc, sizeof (*argvec))) == 0)
......@@ -259,7 +269,8 @@ sendmail_send_message (mailer_t mailer, message_t msg, address_t from,
}
argvec[argc++] = emailfrom;
}
if (!to)
if (!to || mailer_property_is_set (mailer, "READ_RECIPIENTS"))
{
if ((argvec[argc++] = strdup ("-t")) == 0)
{
......
......@@ -915,6 +915,15 @@ smtp_address_add (address_t *paddr, const char *value)
}
static int
_smtp_property_is_set (smtp_t smtp, const char *name)
{
property_t property = NULL;
mailer_get_property (smtp->mailer, &property);
return property_is_set (property, name);
}
static int
_smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
{
int status = 0;
......@@ -939,6 +948,8 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
return status;
}
if (!to || _smtp_property_is_set (smtp, "READ_RECIPIENTS"))
{
if ((status = message_get_header (msg, &header)))
return status;
......@@ -949,7 +960,7 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
smtp_address_add (&smtp->rcpt_to, value);
free (value);
}
else if (status && status != ENOENT)
else if (status != ENOENT)
goto end;
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)
smtp_address_add (&smtp->rcpt_to, value);
free (value);
}
else if (status && status != ENOENT)
else if (status != ENOENT)
goto end;
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)
smtp_address_add (&smtp->rcpt_bcc, value);
free (value);
}
else if (status && status != ENOENT)
else if (status != ENOENT)
goto end;
/* 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)
if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc)))
goto end;
}
end:
......