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 */
}
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,12 +915,21 @@ 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;
header_t header = NULL;
char *value;
/* Get RCPT_TO from TO, or the message. */
if (to)
......@@ -939,45 +948,48 @@ _smtp_set_rcpt (smtp_t smtp, message_t msg, address_t to)
return status;
}
if ((status = message_get_header (msg, &header)))
return status;
status = header_aget_value (header, MU_HEADER_TO, &value);
if (status == 0)
if (!to || _smtp_property_is_set (smtp, "READ_RECIPIENTS"))
{
smtp_address_add (&smtp->rcpt_to, value);
free (value);
}
else if (status && status != ENOENT)
goto end;
if ((status = message_get_header (msg, &header)))
return status;
status = header_aget_value (header, MU_HEADER_CC, &value);
status = header_aget_value (header, MU_HEADER_TO, &value);
if (status == 0)
{
smtp_address_add (&smtp->rcpt_to, value);
free (value);
}
else if (status && status != ENOENT)
goto end;
if (status == 0)
{
smtp_address_add (&smtp->rcpt_to, value);
free (value);
}
else if (status != ENOENT)
goto end;
status = header_aget_value (header, MU_HEADER_BCC, &value);
if (status == 0)
{
smtp_address_add (&smtp->rcpt_bcc, value);
free (value);
}
else if (status && status != ENOENT)
goto end;
status = header_aget_value (header, MU_HEADER_CC, &value);
if (status == 0)
{
smtp_address_add (&smtp->rcpt_to, value);
free (value);
}
else if (status != ENOENT)
goto end;
/* If to or bcc is present, the must be OK. */
if (smtp->rcpt_to && (status = mailer_check_to (smtp->rcpt_to)))
goto end;
status = header_aget_value (header, MU_HEADER_BCC, &value);
if (status == 0)
{
smtp_address_add (&smtp->rcpt_bcc, value);
free (value);
}
else if (status != ENOENT)
goto end;
if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc)))
goto end;
/* If to or bcc is present, the must be OK. */
if (smtp->rcpt_to && (status = mailer_check_to (smtp->rcpt_to)))
goto end;
if (smtp->rcpt_bcc && (status = mailer_check_to (smtp->rcpt_bcc)))
goto end;
}
end:
if (status)
......