1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ All sorts of `reply', `resend', `forward', and similar user commands.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2018 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
6 * SPDX-License-Identifier: BSD-3-Clause
9 * Copyright (c) 1980, 1993
10 * The Regents of the University of California. All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #define n_FILE cmd_resend
39 #ifndef HAVE_AMALGAMATION
43 /* Modify subject we reply to to begin with Re: if it does not already */
44 static char *a_crese_reedit(char const *subj
);
46 /* Fetch these headers, as appropriate */
47 static struct name
*a_crese_reply_to(struct message
*mp
);
48 static struct name
*a_crese_mail_followup_to(struct message
*mp
);
50 /* We honoured Reply-To: and/or Mail-Followup-To:, but *recipients-in-cc* is
51 * set so try to keep "secondary" addressees in Cc:, if possible, */
52 static void a_crese_polite_rt_mft_move(struct message
*mp
, struct header
*hp
,
55 /* References and charset, as appropriate */
56 static void a_crese_make_ref_and_cs(struct message
*mp
, struct header
*head
);
58 /* `reply' and `Lreply' workhorse */
59 static int a_crese_list_reply(int *msgvec
, enum header_flags hf
);
61 /* Get PTF to implementation of command c (i.e., take care for *flipr*) */
62 static int (*a_crese_reply_or_Reply(char c
))(int *, bool_t
);
64 /* Reply to a single message. Extract each name from the message header and
65 * send them off to mail1() */
66 static int a_crese_reply(int *msgvec
, bool_t recipient_record
);
68 /* Reply to a series of messages by simply mailing to the senders and not
69 * messing around with the To: and Cc: lists as in normal reply */
70 static int a_crese_Reply(int *msgvec
, bool_t recipient_record
);
72 /* Forward a message to a new recipient, in the sense of RFC 2822 */
73 static int a_crese_fwd(void *vp
, bool_t recipient_record
);
75 /* Modify the subject we are replying to to begin with Fwd: */
76 static char *a_crese__fwdedit(char *subj
);
78 /* Do the real work of resending */
79 static int a_crese_resend1(void *v
, bool_t add_resent
);
82 a_crese_reedit(char const *subj
){
88 if(subj
!= NULL
&& *subj
!= '\0'){
93 in
.l
= strlen(in
.s
= n_UNCONST(subj
));
94 mime_fromhdr(&in
, &out
, TD_ISPR
| TD_ICONV
);
96 i
= strlen(cp
= subject_re_trim(out
.s
)) +1;
97 /* RFC mandates english "Re: " */
98 newsubj
= n_autorec_alloc(sizeof("Re: ") -1 + i
);
99 memcpy(newsubj
, "Re: ", sizeof("Re: ") -1);
100 memcpy(&newsubj
[sizeof("Re: ") -1], cp
, i
);
109 a_crese_reply_to(struct message
*mp
){
110 char const *cp
, *cp2
;
111 struct name
*rt
, *np
;
115 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
118 if((cp
= ok_vlook(reply_to_honour
)) != NULL
&&
119 (cp2
= hfield1("reply-to", mp
)) != NULL
&&
120 (rt
= checkaddrs(lextract(cp2
, GTO
| gf
), EACM_STRICT
, NULL
)
126 if((n_psonce
& n_PSO_INTERACTIVE
) && !(n_pstate
& n_PS_ROBOT
)){
127 fprintf(n_stdout
, _("Reply-To: header contains:"));
128 for(np
= rt
; np
!= NULL
; np
= np
->n_flink
)
129 fprintf(n_stdout
, " %s", np
->n_name
);
130 putc('\n', n_stdout
);
133 tr
= _("Reply-To %s%s");
134 l
= strlen(tr
) + strlen(rt
->n_name
) + 3 +1;
135 sp
= n_lofi_alloc(l
);
137 snprintf(sp
, l
, tr
, rt
->n_name
, (rt
->n_flink
!= NULL
? "..." : n_empty
));
138 if(n_quadify(cp
, UIZ_MAX
, sp
, TRU1
) <= FAL0
)
148 a_crese_mail_followup_to(struct message
*mp
){
149 char const *cp
, *cp2
;
150 struct name
*mft
, *np
;
154 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
157 if((cp
= ok_vlook(followup_to_honour
)) != NULL
&&
158 (cp2
= hfield1("mail-followup-to", mp
)) != NULL
&&
159 (mft
= checkaddrs(lextract(cp2
, GTO
| gf
), EACM_STRICT
, NULL
)
165 if((n_psonce
& n_PSO_INTERACTIVE
) && !(n_pstate
& n_PS_ROBOT
)){
166 fprintf(n_stdout
, _("Mail-Followup-To: header contains:"));
167 for(np
= mft
; np
!= NULL
; np
= np
->n_flink
)
168 fprintf(n_stdout
, " %s", np
->n_name
);
169 putc('\n', n_stdout
);
172 tr
= _("Followup-To %s%s");
173 l
= strlen(tr
) + strlen(mft
->n_name
) + 3 +1;
174 sp
= n_lofi_alloc(l
);
176 snprintf(sp
, l
, tr
, mft
->n_name
,
177 (mft
->n_flink
!= NULL
? "..." : n_empty
));
178 if(n_quadify(cp
, UIZ_MAX
, sp
, TRU1
) <= FAL0
)
188 a_crese_polite_rt_mft_move(struct message
*mp
, struct header
*hp
,
199 /* We may find that in the end To: is empty but Cc: is not, in which case we
200 * upgrade Cc: to To: and jump back and redo the thing slightly different */
205 struct name
*nnp
, **xpp
, *xp
;
218 /* Try primary, then secondary */
219 for(xp
= hp
->h_mailx_orig_to
; xp
!= NULL
; xp
= xp
->n_flink
)
220 if(!asccasecmp(xp
->n_name
, nnp
->n_name
))
228 for(xp
= hp
->h_mailx_orig_cc
; xp
!= NULL
; xp
= xp
->n_flink
)
229 if(!asccasecmp(xp
->n_name
, nnp
->n_name
))
232 /* If this receiver came in only via R-T: or M-F-T:, place her/him/it in
233 * To: due to lack of a better place */
237 /* Link it at the end to not loose original sort order */
238 if((xp
= *xpp
) != NULL
)
239 while(xp
->n_flink
!= NULL
)
242 if((nnp
->n_blink
= xp
) != NULL
)
247 nnp
->n_type
= (nnp
->n_type
& ~GMASK
) | gf
;
250 /* If afterwards only Cc: data remains, upgrade all of it to To: */
251 if(hp
->h_to
== NULL
){
259 for(hp
->h_to
= np
; np
!= NULL
; np
= np
->n_flink
)
260 np
->n_type
= (np
->n_type
& ~GMASK
) | GTO
;
266 a_crese_make_ref_and_cs(struct message
*mp
, struct header
*head
) /* TODO ASAP*/
269 char *oldref
, *oldmsgid
, *newref
;
270 size_t oldreflen
= 0, oldmsgidlen
= 0, reflen
;
275 oldref
= hfield1("references", mp
);
276 oldmsgid
= hfield1("message-id", mp
);
277 if (oldmsgid
== NULL
|| *oldmsgid
== '\0') {
284 oldreflen
= strlen(oldref
);
285 reflen
+= oldreflen
+ 2;
288 oldmsgidlen
= strlen(oldmsgid
);
289 reflen
+= oldmsgidlen
;
292 newref
= n_alloc(reflen
);
293 if (oldref
!= NULL
) {
294 memcpy(newref
, oldref
, oldreflen
+1);
295 if (oldmsgid
!= NULL
) {
296 newref
[oldreflen
++] = ',';
297 newref
[oldreflen
++] = ' ';
298 memcpy(newref
+ oldreflen
, oldmsgid
, oldmsgidlen
+1);
301 memcpy(newref
, oldmsgid
, oldmsgidlen
+1);
302 n
= extract(newref
, GREF
);
305 /* Limit number of references TODO better on parser side */
306 while (n
->n_flink
!= NULL
)
308 for (i
= 1; i
<= REFERENCES_MAX
; ++i
) {
309 if (n
->n_blink
!= NULL
)
316 if (ok_blook(reply_in_same_charset
) &&
317 (ccp
= hfield1("content-type", mp
)) != NULL
){
318 if((head
->h_charset
= ccp
= mime_param_get("charset", ccp
)) != NULL
){
319 if((ccp
= n_iconv_normalize_name(ccp
)) != NULL
)
320 ccp
= n_charsetalias_expand(ccp
);
321 head
->h_charset
= ccp
;
329 a_crese_list_reply(int *msgvec
, enum header_flags hf
){
332 char const *cp
, *cp2
;
334 struct name
*rt
, *mft
, *np
;
337 n_pstate_err_no
= n_ERR_NONE
;
339 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
342 n_autorec_relax_create();
343 mp
= &message
[*msgvec
- 1];
347 memset(&head
, 0, sizeof head
);
349 head
.h_subject
= a_crese_reedit(hfield1("subject", mp
));
350 head
.h_mailx_command
= (hf
& HF_LIST_REPLY
) ? "Lreply" : "reply";
351 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
352 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
353 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
354 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
356 /* First of all check for Reply-To: then Mail-Followup-To:, because these,
357 * if honoured, take precedence over anything else. We will join the
358 * resulting list together if so desired.
359 * So if we shall honour R-T: or M-F-T:, then these are our receivers! */
360 rt
= a_crese_reply_to(mp
);
361 mft
= a_crese_mail_followup_to(mp
);
363 if(rt
!= NULL
|| mft
!= NULL
){
366 head
.h_mft
= n_namelist_dup(np
, GTO
| gf
); /* xxx GTO: no "clone"! */
368 /* Optionally do not propagate a receiver that originally was in
369 * secondary Cc: to the primary To: list */
370 if(ok_blook(recipients_in_cc
)){
371 a_crese_polite_rt_mft_move(mp
, &head
, np
);
373 head
.h_mailx_raw_cc
= n_namelist_dup(head
.h_cc
, GCC
| gf
);
374 head
.h_cc
= n_alternates_remove(head
.h_cc
, FAL0
);
378 head
.h_mailx_raw_to
= n_namelist_dup(head
.h_to
, GTO
| gf
);
379 head
.h_to
= n_alternates_remove(head
.h_to
, FAL0
);
381 for(np
= head
.h_to
; np
!= NULL
; np
= np
->n_flink
)
382 assert((np
->n_type
& GMASK
) == GTO
);
383 for(np
= head
.h_cc
; np
!= NULL
; np
= np
->n_flink
)
384 assert((np
->n_type
& GMASK
) == GCC
);
386 goto jrecipients_done
;
389 /* Otherwise do the normal From: / To: / Cc: dance */
391 cp2
= n_header_senderfield_of(mp
);
395 if(ok_blook(recipients_in_cc
) && (cp
= hfield1("to", mp
)) != NULL
)
396 np
= lextract(cp
, GCC
| gf
);
397 if((cp
= hfield1("cc", mp
)) != NULL
){
400 if((x
= lextract(cp
, GCC
| gf
)) != NULL
)
404 head
.h_mailx_raw_cc
= n_namelist_dup(np
, GCC
| gf
);
405 head
.h_cc
= n_alternates_remove(np
, FAL0
);
411 np
= lextract(cp2
, GTO
| gf
);
412 if(!ok_blook(recipients_in_cc
) && (cp
= hfield1("to", mp
)) != NULL
){
415 if((x
= lextract(cp
, GTO
| gf
)) != NULL
)
418 /* Delete my name from reply list, and with it, all my alternate names */
420 head
.h_mailx_raw_to
= n_namelist_dup(np
, GTO
| gf
);
421 np
= n_alternates_remove(np
, FAL0
);
422 /* The user may have send this to himself, don't ignore that */
424 np
= lextract(cp2
, GTO
| gf
);
425 head
.h_mailx_raw_to
= n_namelist_dup(np
, GTO
| gf
);
432 /* For list replies we want to automatically recognize the list address
433 * given in the List-Post: header, so that we will not throw away a possible
434 * corresponding receiver: temporarily "`mlist' the List-Post: address" */
435 if((hf
& HF_LIST_REPLY
) && (cp
= hfield1("list-post", mp
)) != NULL
){
438 if((x
= lextract(cp
, GEXTRA
| GSKIN
)) == NULL
|| x
->n_flink
!= NULL
||
439 (cp
= url_mailto_to_address(x
->n_name
)) == NULL
||
440 /* XXX terribly wasteful to create a new name, and can't we find
441 * XXX a way to mitigate that?? */
442 is_addr_invalid(x
= nalloc(cp
, GEXTRA
| GSKIN
), EACM_STRICT
)){
443 if(n_poption
& n_PO_D_V
)
444 n_err(_("Message contains invalid List-Post: header\n"));
446 /* A special case has been seen on e.g. ietf-announce@ietf.org:
447 * these usually post to multiple groups, with ietf-announce@
448 * in List-Post:, but with Reply-To: set to ietf@ietf.org (since
449 * -announce@ is only used for announcements, say).
450 * So our desire is to honour this request and actively overwrite
451 * List-Post: for our purpose; but only if its a single address.
452 * However, to avoid ambiguities with users that place themselve in
453 * Reply-To: and mailing lists which don't overwrite this (or only
454 * extend this, shall such exist), only do so if reply_to exists of
455 * a single address which points to the same domain as List-Post: */
456 if(rt
!= NULL
&& rt
->n_flink
== NULL
&&
457 name_is_same_domain(x
, rt
))
458 cp
= rt
->n_name
; /* rt is EACM_STRICT tested */
462 /* XXX is_mlist_mp()?? */
463 if(is_mlist(cp
, FAL0
) == MLIST_OTHER
)
464 head
.h_list_post
= cp
;
468 /* In case of list replies we actively sort out any non-list recipient */
469 if(hf
& HF_LIST_REPLY
){
470 struct name
**nhpp
, *nhp
, *tail
;
472 cp
= head
.h_list_post
;
474 nhp
= *(nhpp
= &head
.h_to
);
477 for(tail
= NULL
; nhp
!= NULL
;){
481 /* XXX is_mlist_mp()?? */
482 if((cp
!= NULL
&& !asccasecmp(cp
, np
->n_name
)) ||
483 is_mlist(np
->n_name
, FAL0
) != MLIST_OTHER
){
484 if((np
->n_blink
= tail
) != NULL
)
492 if(nhpp
== &head
.h_to
){
493 nhp
= *(nhpp
= &head
.h_cc
);
498 /* For `Lreply' only, fail immediately with DESTADDRREQ if there are no
499 * receivers at all! */
500 if(head
.h_to
== NULL
&& head
.h_cc
== NULL
){
501 n_err(_("No recipients specified for `Lreply'\n"));
503 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
511 /* Move Cc: to To: as appropriate! */
512 if(head
.h_to
== NULL
&& (np
= head
.h_cc
) != NULL
){
514 for(head
.h_to
= np
; np
!= NULL
; np
= np
->n_flink
)
515 np
->n_type
= (np
->n_type
& ~GMASK
) | GTO
;
518 a_crese_make_ref_and_cs(mp
, &head
);
520 if(n_mail1((n_MAILSEND_HEADERS_PRINT
|
521 (hf
& HF_RECIPIENT_RECORD
? n_MAILSEND_RECORD_RECIPIENT
: 0)),
522 &head
, mp
, NULL
) != OKAY
){
526 if(ok_blook(markanswered
) && !(mp
->m_flag
& MANSWERED
))
527 mp
->m_flag
|= MANSWER
| MANSWERED
;
528 n_autorec_relax_gut();
532 /* TODO message (error) ring.., less sleep */
533 if(n_psonce
& n_PSO_INTERACTIVE
){
535 _("Waiting a second before proceeding to the next message..\n"));
537 n_msleep(1000, FAL0
);
544 return (msgvec
== NULL
);
548 (*a_crese_reply_or_Reply(char c
))(int *, bool_t
){
549 int (*rv
)(int*, bool_t
);
552 rv
= (ok_blook(flipr
) ^ (c
== 'R')) ? &a_crese_Reply
: &a_crese_reply
;
558 a_crese_reply(int *msgvec
, bool_t recipient_record
){
562 rv
= a_crese_list_reply(msgvec
,
563 (recipient_record
? HF_RECIPIENT_RECORD
: HF_NONE
));
569 a_crese_Reply(int *msgvec
, bool_t recipient_record
){
576 memset(&head
, 0, sizeof head
);
577 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
579 for(ap
= msgvec
; *ap
!= 0; ++ap
){
582 mp
= &message
[*ap
- 1];
586 if((np
= a_crese_reply_to(mp
)) == NULL
)
587 np
= lextract(n_header_senderfield_of(mp
), GTO
| gf
);
588 head
.h_to
= cat(head
.h_to
, np
);
591 mp
= &message
[msgvec
[0] - 1];
592 head
.h_subject
= hfield1("subject", mp
);
593 head
.h_subject
= a_crese_reedit(head
.h_subject
);
594 a_crese_make_ref_and_cs(mp
, &head
);
595 head
.h_mailx_command
= "Reply";
596 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
597 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
598 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
599 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
601 if(ok_blook(recipients_in_cc
)){
602 a_crese_polite_rt_mft_move(mp
, &head
, head
.h_to
);
604 head
.h_mailx_raw_cc
= n_namelist_dup(head
.h_cc
, GCC
| gf
);
605 head
.h_cc
= n_alternates_remove(head
.h_cc
, FAL0
);
607 head
.h_mailx_raw_to
= n_namelist_dup(head
.h_to
, GTO
| gf
);
608 head
.h_to
= n_alternates_remove(head
.h_to
, FAL0
);
610 if(ok_blook(quote_as_attachment
)){
611 head
.h_attach
= n_autorec_calloc(1, sizeof *head
.h_attach
);
612 head
.h_attach
->a_msgno
= *msgvec
;
613 head
.h_attach
->a_content_description
= _("Original message content");
616 if(n_mail1(((recipient_record
? n_MAILSEND_RECORD_RECIPIENT
: 0) |
617 n_MAILSEND_HEADERS_PRINT
), &head
, mp
, NULL
) != OKAY
){
622 if(ok_blook(markanswered
) && !(mp
->m_flag
& MANSWERED
))
623 mp
->m_flag
|= MANSWER
| MANSWERED
;
626 return (msgvec
== NULL
);
630 a_crese_fwd(void *vp
, bool_t recipient_record
){
634 bool_t forward_as_attachment
;
636 struct n_cmd_arg
*cap
;
637 struct n_cmd_arg_ctx
*cacp
;
642 msgvec
= cap
->ca_arg
.ca_msglist
;
646 if(cap
->ca_arg
.ca_str
.s
[0] == '\0'){
647 if(!(n_pstate
& (n_PS_HOOK_MASK
| n_PS_ROBOT
)) || (n_poption
& n_PO_D_V
))
648 n_err(_("No recipient specified.\n"));
649 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
653 forward_as_attachment
= ok_blook(forward_as_attachment
);
654 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
656 memset(&head
, 0, sizeof head
);
657 head
.h_to
= lextract(cap
->ca_arg
.ca_str
.s
,
658 (GTO
| (ok_blook(fullnames
) ? GFULL
: GSKIN
)));
660 mp
= &message
[*msgvec
- 1];
663 head
.h_subject
= hfield1("subject", mp
);
664 head
.h_subject
= a_crese__fwdedit(head
.h_subject
);
665 head
.h_mailx_command
= "forward";
666 head
.h_mailx_raw_to
= n_namelist_dup(head
.h_to
, GTO
| gf
);
667 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
668 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
669 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
670 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
672 if(forward_as_attachment
){
673 head
.h_attach
= n_autorec_calloc(1, sizeof *head
.h_attach
);
674 head
.h_attach
->a_msgno
= *msgvec
;
675 head
.h_attach
->a_content_description
= _("Forwarded message");
678 rv
= (n_mail1((n_MAILSEND_IS_FWD
|
679 (recipient_record
? n_MAILSEND_RECORD_RECIPIENT
: 0) |
680 n_MAILSEND_HEADERS_PRINT
), &head
,
681 (forward_as_attachment
? NULL
: mp
), NULL
) != OKAY
); /* reverse! */
688 a_crese__fwdedit(char *subj
){
695 if(subj
== NULL
|| *subj
== '\0')
700 mime_fromhdr(&in
, &out
, TD_ISPR
| TD_ICONV
);
702 newsubj
= n_autorec_alloc(out
.l
+ 6);
703 if(!ascncasecmp(out
.s
, "Fwd: ", sizeof("Fwd: ") -1)) /* TODO EXTEND SUPP. */
704 memcpy(newsubj
, out
.s
, out
.l
+1);
706 memcpy(newsubj
, "Fwd: ", 5); /* TODO ..a la subject_re_trim()! */
707 memcpy(&newsubj
[5], out
.s
, out
.l
+1);
717 a_crese_resend1(void *vp
, bool_t add_resent
){
719 struct name
*myto
, *myrawto
;
721 int *msgvec
, rv
, *ip
;
722 struct n_cmd_arg
*cap
;
723 struct n_cmd_arg_ctx
*cacp
;
728 msgvec
= cap
->ca_arg
.ca_msglist
;
731 n_pstate_err_no
= n_ERR_DESTADDRREQ
;
733 if(cap
->ca_arg
.ca_str
.s
[0] == '\0'){
734 if(!(n_pstate
& (n_PS_HOOK_MASK
| n_PS_ROBOT
)) || (n_poption
& n_PO_D_V
))
735 n_err(_("No recipient specified.\n"));
739 gf
= ok_blook(fullnames
) ? GFULL
| GSKIN
: GSKIN
;
741 myrawto
= nalloc(cap
->ca_arg
.ca_str
.s
, GTO
| gf
);
742 myto
= usermap(n_namelist_dup(myrawto
, myrawto
->n_type
), FAL0
);
744 myto
= n_alternates_remove(myto
, TRU1
);
748 n_autorec_relax_create();
749 for(ip
= msgvec
; *ip
!= 0; ++ip
){
752 mp
= &message
[*ip
- 1];
756 memset(&head
, 0, sizeof head
);
758 head
.h_mailx_command
= "resend";
759 head
.h_mailx_raw_to
= myrawto
;
760 head
.h_mailx_orig_from
= lextract(hfield1("from", mp
), GIDENT
| gf
);
761 head
.h_mailx_orig_to
= lextract(hfield1("to", mp
), GTO
| gf
);
762 head
.h_mailx_orig_cc
= lextract(hfield1("cc", mp
), GCC
| gf
);
763 head
.h_mailx_orig_bcc
= lextract(hfield1("bcc", mp
), GBCC
| gf
);
765 if(resend_msg(mp
, &head
, add_resent
) != OKAY
){
766 /* n_autorec_relax_gut(); XXX but is handled automatically? */
769 n_autorec_relax_unroll();
771 n_autorec_relax_gut();
773 n_pstate_err_no
= n_ERR_NONE
;
785 rv
= (*a_crese_reply_or_Reply('r'))(vp
, FAL0
);
791 c_replyall(void *vp
){
795 rv
= a_crese_reply(vp
, FAL0
);
801 c_replysender(void *vp
){
805 rv
= a_crese_Reply(vp
, FAL0
);
815 rv
= (*a_crese_reply_or_Reply('R'))(vp
, FAL0
);
825 rv
= a_crese_list_reply(vp
, HF_LIST_REPLY
);
831 c_followup(void *vp
){
835 rv
= (*a_crese_reply_or_Reply('r'))(vp
, TRU1
);
841 c_followupall(void *vp
){
845 rv
= a_crese_reply(vp
, TRU1
);
851 c_followupsender(void *vp
){
855 rv
= a_crese_Reply(vp
, TRU1
);
861 c_Followup(void *vp
){
865 rv
= (*a_crese_reply_or_Reply('R'))(vp
, TRU1
);
875 rv
= a_crese_fwd(vp
, FAL0
);
885 rv
= a_crese_fwd(vp
, TRU1
);
895 rv
= a_crese_resend1(vp
, TRU1
);
905 rv
= a_crese_resend1(vp
, FAL0
);