static char SccsId
[] = "@(#)recipient.c 3.8 %G%";
** SENDTO -- Designate a send list.
** The parameter is a comma-separated list of people to send to.
** This routine arranges to send to all of them.
** list -- the send list.
** copyf -- the copy flag; passed to parse.
/* more keeps track of what the previous delimiter was */
/* find the end of this address */
while (*p
== ' ' || *p
== '\t')
while ((c
= *p
++) != '\0' && c
!= ',' && c
!= '\n')
if ((a
= parse(q
, (ADDRESS
*) NULL
, copyf
)) == NULL
)
/* arrange to send to this person */
** RECIPIENT -- Designate a message recipient
** Saves the named person for future mailing.
** a -- the (preparsed) address header for the recipient.
register struct mailer
*m
;
printf("recipient(%s)\n", To
);
/* break aliasing loops */
if (AliasLevel
> MAXRCRSN
)
usrerr("aliasing/forwarding loop broken");
** Do sickly crude mapping for program mailing, etc.
if (a
->q_mailer
== MN_LOCAL
)
usrerr("Cannot mail directly to programs");
** Look up this person in the recipient list. If they
** are there already, return, otherwise continue.
** If the list is empty, just add it.
for (q
= m
->m_sendq
; q
!= NULL
; pq
= q
, q
= q
->q_next
)
if (!ForceMail
&& sameaddr(q
, a
, FALSE
))
printf("(%s in sendq)\n", a
->q_paddr
);
if (Verbose
&& !bitset(QDONTSEND
, a
->q_flags
))
message(Arpa_Info
, "duplicate supressed");
/* add address on list */
** Alias the name and handle :include: specs.
if (a
->q_mailer
== MN_LOCAL
)
if (strncmp(a
->q_user
, ":include:", 9) == 0)
message(Arpa_Info
, "including file %s", &a
->q_user
[9]);
include(&a
->q_user
[9], " sending");
** If the user is local and still being sent, verify that
** the address is good. If it is, try to forward.
** If the address is already good, we have a forwarding
** loop. This can be broken by just sending directly to
** the user (which is probably correct anyway).
if (!bitset(QDONTSEND
, a
->q_flags
) && a
->q_mailer
== MN_LOCAL
)
/* see if this is to a file */
if ((p
= rindex(buf
, '/')) != NULL
)
/* check if writable or creatable */
if ((access(buf
, 0) >= 0) ?
(*p
= '\0', access(buf
, 3) < 0))
giveresponse(EX_CANTCREAT
, TRUE
, m
);
register struct passwd
*pw
;
extern struct passwd
*getpwnam();
giveresponse(EX_NOUSER
, TRUE
, m
);
a
->q_home
= newstr(pw
->pw_dir
);
if (strcmp(buf
, a
->q_user
) == 0)
** INCLUDE -- handle :include: specification.
** fname -- filename to include.
** msg -- message to print in verbose mode.
** reads the :include: file and sends to everyone
usrerr("Cannot open %s", fname
);
/* read the file -- each line is a comma-separated list. */
while (fgets(buf
, sizeof buf
, fp
) != NULL
)
register char *p
= index(buf
, '\n');
message(Arpa_Info
, "%s to %s", msg
, buf
);