NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
DOXYGEN
send.c
Go to the documentation of this file.
1 
30 #include "config.h"
31 #include <errno.h>
32 #include <limits.h>
33 #include <locale.h>
34 #include <regex.h>
35 #include <stdbool.h>
36 #include <stdio.h>
37 #include <string.h>
38 #include <sys/stat.h>
39 #include <time.h>
40 #include <unistd.h>
41 #include "mutt/mutt.h"
42 #include "address/lib.h"
43 #include "config/lib.h"
44 #include "email/lib.h"
45 #include "core/lib.h"
46 #include "mutt.h"
47 #include "send.h"
48 #include "alias.h"
49 #include "compose.h"
50 #include "context.h"
51 #include "copy.h"
52 #include "curs_lib.h"
53 #include "edit.h"
54 #include "filter.h"
55 #include "globals.h"
56 #include "handler.h"
57 #include "hdrline.h"
58 #include "hook.h"
59 #include "mutt_attach.h"
60 #include "mutt_body.h"
61 #include "mutt_header.h"
62 #include "mutt_logging.h"
63 #include "mutt_parse.h"
64 #include "muttlib.h"
65 #include "ncrypt/ncrypt.h"
66 #include "options.h"
67 #include "pattern.h"
68 #include "protos.h"
69 #include "recvattach.h"
70 #include "rfc3676.h"
71 #include "sendlib.h"
72 #include "smtp.h"
73 #include "sort.h"
74 #ifdef USE_NNTP
75 #include "mx.h"
76 #include "nntp/nntp.h"
77 #endif
78 #ifdef MIXMASTER
79 #include "remailer.h"
80 #endif
81 #ifdef USE_NOTMUCH
82 #include "notmuch/mutt_notmuch.h"
83 #endif
84 #ifdef USE_IMAP
85 #include "imap/imap.h"
86 #endif
87 #ifdef USE_AUTOCRYPT
88 #include "autocrypt/autocrypt.h"
89 #endif
90 
91 /* These Config Variables are only used in send.c */
92 unsigned char C_AbortNoattach;
94 unsigned char C_AbortNosubject;
95 unsigned char C_AbortUnmodified;
108 unsigned char C_FccAttach;
114 unsigned char C_ForwardEdit;
117 bool C_Hdrs;
118 unsigned char C_HonorFollowupTo;
120 unsigned char C_Include;
121 bool C_Metoo;
127 unsigned char C_Recall;
129 unsigned char C_ReplyTo;
134 char *C_Signature;
136 bool C_UseFrom;
137 
142 static void append_signature(FILE *fp)
143 {
144  FILE *fp_tmp = NULL;
145  pid_t pid;
146 
147  if (C_Signature && (fp_tmp = mutt_open_read(C_Signature, &pid)))
148  {
149  if (C_SigDashes)
150  fputs("\n-- \n", fp);
151  mutt_file_copy_stream(fp_tmp, fp);
152  mutt_file_fclose(&fp_tmp);
153  if (pid != -1)
154  mutt_wait_filter(pid);
155  }
156 }
157 
164 static void remove_user(struct AddressList *al, bool leave_only)
165 {
166  struct Address *a = NULL, *tmp = NULL;
167  TAILQ_FOREACH_SAFE(a, al, entries, tmp)
168  {
169  if (mutt_addr_is_user(a) && (!leave_only || TAILQ_NEXT(a, entries)))
170  {
171  TAILQ_REMOVE(al, a, entries);
172  mutt_addr_free(&a);
173  }
174  }
175 }
176 
183 static void add_mailing_lists(struct AddressList *out, const struct AddressList *t,
184  const struct AddressList *c)
185 {
186  const struct AddressList *const als[] = { t, c };
187 
188  for (size_t i = 0; i < mutt_array_size(als); ++i)
189  {
190  const struct AddressList *al = als[i];
191  struct Address *a = NULL;
192  TAILQ_FOREACH(a, al, entries)
193  {
194  if (!a->group && mutt_is_mail_list(a))
195  {
197  }
198  }
199  }
200 }
201 
210 int mutt_edit_address(struct AddressList *al, const char *field, bool expand_aliases)
211 {
212  char buf[8192];
213  char *err = NULL;
214  int idna_ok = 0;
215 
216  do
217  {
218  buf[0] = '\0';
220  mutt_addrlist_write(buf, sizeof(buf), al, false);
221  if (mutt_get_field(field, buf, sizeof(buf), MUTT_ALIAS) != 0)
222  return -1;
224  mutt_addrlist_parse2(al, buf);
225  if (expand_aliases)
227  idna_ok = mutt_addrlist_to_intl(al, &err);
228  if (idna_ok != 0)
229  {
230  mutt_error(_("Bad IDN: '%s'"), err);
231  FREE(&err);
232  }
233  } while (idna_ok != 0);
234  return 0;
235 }
236 
244 static int edit_envelope(struct Envelope *en, SendFlags flags)
245 {
246  char buf[8192];
247 
248 #ifdef USE_NNTP
249  if (OptNewsSend)
250  {
251  if (en->newsgroups)
252  mutt_str_strfcpy(buf, en->newsgroups, sizeof(buf));
253  else
254  buf[0] = '\0';
255  if (mutt_get_field("Newsgroups: ", buf, sizeof(buf), 0) != 0)
256  return -1;
257  FREE(&en->newsgroups);
258  en->newsgroups = mutt_str_strdup(buf);
259 
260  if (en->followup_to)
261  mutt_str_strfcpy(buf, en->followup_to, sizeof(buf));
262  else
263  buf[0] = '\0';
264  if (C_AskFollowUp && (mutt_get_field("Followup-To: ", buf, sizeof(buf), 0) != 0))
265  {
266  return -1;
267  }
268  FREE(&en->followup_to);
269  en->followup_to = mutt_str_strdup(buf);
270 
271  if (en->x_comment_to)
272  mutt_str_strfcpy(buf, en->x_comment_to, sizeof(buf));
273  else
274  buf[0] = '\0';
275  if (C_XCommentTo && C_AskXCommentTo &&
276  (mutt_get_field("X-Comment-To: ", buf, sizeof(buf), 0) != 0))
277  {
278  return -1;
279  }
280  FREE(&en->x_comment_to);
281  en->x_comment_to = mutt_str_strdup(buf);
282  }
283  else
284 #endif
285  {
286  if ((mutt_edit_address(&en->to, _("To: "), true) == -1) || TAILQ_EMPTY(&en->to))
287  return -1;
288  if (C_Askcc && (mutt_edit_address(&en->cc, _("Cc: "), true) == -1))
289  return -1;
290  if (C_Askbcc && (mutt_edit_address(&en->bcc, _("Bcc: "), true) == -1))
291  return -1;
293  (mutt_edit_address(&en->from, "From: ", true) == -1))
294  {
295  return -1;
296  }
297  }
298 
299  if (en->subject)
300  {
301  if (C_FastReply)
302  return 0;
303  else
304  mutt_str_strfcpy(buf, en->subject, sizeof(buf));
305  }
306  else
307  {
308  const char *p = NULL;
309 
310  buf[0] = '\0';
311  struct ListNode *uh = NULL;
312  STAILQ_FOREACH(uh, &UserHeader, entries)
313  {
314  size_t plen = mutt_str_startswith(uh->data, "subject:", CASE_IGNORE);
315  if (plen)
316  {
317  p = mutt_str_skip_email_wsp(uh->data + plen);
318  mutt_str_strfcpy(buf, p, sizeof(buf));
319  }
320  }
321  }
322 
323  if ((mutt_get_field(_("Subject: "), buf, sizeof(buf), 0) != 0) ||
324  (!buf[0] &&
325  (query_quadoption(C_AbortNosubject, _("No subject, abort?")) != MUTT_NO)))
326  {
327  mutt_message(_("No subject, aborting"));
328  return -1;
329  }
330  mutt_str_replace(&en->subject, buf);
331 
332  return 0;
333 }
334 
335 #ifdef USE_NNTP
336 
343 static char *nntp_get_header(const char *s)
344 {
345  SKIPWS(s);
346  return mutt_str_strdup(s);
347 }
348 #endif
349 
354 static void process_user_recips(struct Envelope *env)
355 {
356  struct ListNode *uh = NULL;
357  STAILQ_FOREACH(uh, &UserHeader, entries)
358  {
359  size_t plen;
360  if ((plen = mutt_str_startswith(uh->data, "to:", CASE_IGNORE)))
361  mutt_addrlist_parse(&env->to, uh->data + plen);
362  else if ((plen = mutt_str_startswith(uh->data, "cc:", CASE_IGNORE)))
363  mutt_addrlist_parse(&env->cc, uh->data + plen);
364  else if ((plen = mutt_str_startswith(uh->data, "bcc:", CASE_IGNORE)))
365  mutt_addrlist_parse(&env->bcc, uh->data + plen);
366 #ifdef USE_NNTP
367  else if ((plen = mutt_str_startswith(uh->data, "newsgroups:", CASE_IGNORE)))
368  env->newsgroups = nntp_get_header(uh->data + plen);
369  else if ((plen = mutt_str_startswith(uh->data, "followup-to:", CASE_IGNORE)))
370  env->followup_to = nntp_get_header(uh->data + plen);
371  else if ((plen = mutt_str_startswith(uh->data, "x-comment-to:", CASE_IGNORE)))
372  env->x_comment_to = nntp_get_header(uh->data + plen);
373 #endif
374  }
375 }
376 
381 static void process_user_header(struct Envelope *env)
382 {
383  struct ListNode *uh = NULL;
384  STAILQ_FOREACH(uh, &UserHeader, entries)
385  {
386  size_t plen;
387  if ((plen = mutt_str_startswith(uh->data, "from:", CASE_IGNORE)))
388  {
389  /* User has specified a default From: address. Remove default address */
390  mutt_addrlist_clear(&env->from);
391  mutt_addrlist_parse(&env->from, uh->data + plen);
392  }
393  else if ((plen = mutt_str_startswith(uh->data, "reply-to:", CASE_IGNORE)))
394  {
396  mutt_addrlist_parse(&env->reply_to, uh->data + plen);
397  }
398  else if ((plen = mutt_str_startswith(uh->data, "message-id:", CASE_IGNORE)))
399  {
400  char *tmp = mutt_extract_message_id(uh->data + plen, NULL);
401  if (mutt_addr_valid_msgid(tmp))
402  {
403  FREE(&env->message_id);
404  env->message_id = tmp;
405  }
406  else
407  FREE(&tmp);
408  }
409  else if (!mutt_str_startswith(uh->data, "to:", CASE_IGNORE) &&
410  !mutt_str_startswith(uh->data, "cc:", CASE_IGNORE) &&
411  !mutt_str_startswith(uh->data, "bcc:", CASE_IGNORE) &&
412 #ifdef USE_NNTP
413  !mutt_str_startswith(uh->data, "newsgroups:", CASE_IGNORE) &&
414  !mutt_str_startswith(uh->data, "followup-to:", CASE_IGNORE) &&
415  !mutt_str_startswith(uh->data, "x-comment-to:", CASE_IGNORE) &&
416 #endif
417  !mutt_str_startswith(uh->data, "supersedes:", CASE_IGNORE) &&
418  !mutt_str_startswith(uh->data, "subject:", CASE_IGNORE) &&
419  !mutt_str_startswith(uh->data, "return-path:", CASE_IGNORE))
420  {
422  }
423  }
424 }
425 
432 void mutt_forward_intro(struct Mailbox *m, struct Email *e, FILE *fp)
433 {
434  if (!C_ForwardAttributionIntro || !fp)
435  return;
436 
437  char buf[1024];
438  setlocale(LC_TIME, NONULL(C_AttributionLocale));
439  mutt_make_string(buf, sizeof(buf), C_ForwardAttributionIntro, NULL, m, e);
440  setlocale(LC_TIME, "");
441  fputs(buf, fp);
442  fputs("\n\n", fp);
443 }
444 
451 void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp)
452 {
453  if (!C_ForwardAttributionTrailer || !fp)
454  return;
455 
456  char buf[1024];
457  setlocale(LC_TIME, NONULL(C_AttributionLocale));
458  mutt_make_string(buf, sizeof(buf), C_ForwardAttributionTrailer, NULL, m, e);
459  setlocale(LC_TIME, "");
460  fputc('\n', fp);
461  fputs(buf, fp);
462  fputc('\n', fp);
463 }
464 
473 static int include_forward(struct Mailbox *m, struct Email *e, FILE *fp_out)
474 {
475  CopyHeaderFlags chflags = CH_DECODE;
477 
480 
481  if ((WithCrypto != 0) && (e->security & SEC_ENCRYPT) && C_ForwardDecode)
482  {
483  /* make sure we have the user's passphrase before proceeding... */
485  return -1;
486  }
487 
488  mutt_forward_intro(m, e, fp_out);
489 
490  if (C_ForwardDecode)
491  {
492  cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
493  if (C_Weed)
494  {
495  chflags |= CH_WEED | CH_REORDER;
496  cmflags |= MUTT_CM_WEED;
497  }
498  }
499  if (C_ForwardQuote)
500  cmflags |= MUTT_CM_PREFIX;
501 
502  /* wrapping headers for forwarding is considered a display
503  * rather than send action */
504  chflags |= CH_DISPLAY;
505 
506  mutt_copy_message(fp_out, m, e, cmflags, chflags);
507  mutt_forward_trailer(m, e, fp_out);
508  return 0;
509 }
510 
520 static int inline_forward_attachments(struct Mailbox *m, struct Email *e,
521  struct Body ***plast, int *forwardq)
522 {
523  struct Body **last = *plast;
524  struct Body *body = NULL;
525  struct Message *msg = NULL;
526  struct AttachCtx *actx = NULL;
527  int rc = 0, i;
528 
531 
532  msg = mx_msg_open(m, e->msgno);
533  if (!msg)
534  return -1;
535 
536  actx = mutt_mem_calloc(1, sizeof(*actx));
537  actx->email = e;
538  actx->fp_root = msg->fp;
539 
540  mutt_generate_recvattach_list(actx, actx->email, actx->email->content,
541  actx->fp_root, -1, 0, 0);
542 
543  for (i = 0; i < actx->idxlen; i++)
544  {
545  body = actx->idx[i]->content;
546  if ((body->type != TYPE_MULTIPART) && !mutt_can_decode(body) &&
547  !((body->type == TYPE_APPLICATION) &&
548  ((mutt_str_strcasecmp(body->subtype, "pgp-signature") == 0) ||
549  (mutt_str_strcasecmp(body->subtype, "x-pkcs7-signature") == 0) ||
550  (mutt_str_strcasecmp(body->subtype, "pkcs7-signature") == 0))))
551  {
552  /* Ask the quadoption only once */
553  if (*forwardq == -1)
554  {
556  /* L10N:
557  This is the prompt for $forward_attachments.
558  When inline forwarding ($mime_forward answered "no"), this prompts
559  whether to add non-decodable attachments from the original email.
560  Text/plain parts and the like will already be included in the
561  message contents, but other attachment, such as PDF files, will also
562  be added as attachments to the new mail, if this is answered yes.
563  */
564  _("Forward attachments?"));
565  if (*forwardq != MUTT_YES)
566  {
567  if (*forwardq == -1)
568  rc = -1;
569  goto cleanup;
570  }
571  }
572  if (mutt_body_copy(actx->idx[i]->fp, last, body) == -1)
573  {
574  rc = -1;
575  goto cleanup;
576  }
577  last = &((*last)->next);
578  }
579  }
580 
581 cleanup:
582  *plast = last;
583  mx_msg_close(m, &msg);
584  mutt_actx_free(&actx);
585  return rc;
586 }
587 
597 int mutt_inline_forward(struct Mailbox *m, struct Email *e_edit,
598  struct Email *e_cur, FILE *out)
599 {
600  int i, forwardq = -1;
601  struct Body **last = NULL;
602 
603  if (e_cur)
604  include_forward(m, e_cur, out);
605  else
606  for (i = 0; i < m->vcount; i++)
607  if (m->emails[m->v2r[i]]->tagged)
608  include_forward(m, m->emails[m->v2r[i]], out);
609 
611  {
612  last = &e_edit->content;
613  while (*last)
614  last = &((*last)->next);
615 
616  if (e_cur)
617  {
618  if (inline_forward_attachments(m, e_cur, &last, &forwardq) != 0)
619  return -1;
620  }
621  else
622  for (i = 0; i < m->vcount; i++)
623  if (m->emails[m->v2r[i]]->tagged)
624  {
625  if (inline_forward_attachments(m, m->emails[m->v2r[i]], &last, &forwardq) != 0)
626  return -1;
627  if (forwardq == MUTT_NO)
628  break;
629  }
630  }
631 
632  return 0;
633 }
634 
641 void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *fp_out)
642 {
643  if (!C_Attribution || !fp_out)
644  return;
645 
646  char buf[1024];
647  setlocale(LC_TIME, NONULL(C_AttributionLocale));
648  mutt_make_string(buf, sizeof(buf), C_Attribution, NULL, m, e);
649  setlocale(LC_TIME, "");
650  fputs(buf, fp_out);
651  fputc('\n', fp_out);
652 }
653 
660 void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *fp_out)
661 {
662  if (!C_PostIndentString || !fp_out)
663  return;
664 
665  char buf[256];
666  mutt_make_string(buf, sizeof(buf), C_PostIndentString, NULL, m, e);
667  fputs(buf, fp_out);
668  fputc('\n', fp_out);
669 }
670 
679 static int include_reply(struct Mailbox *m, struct Email *e, FILE *fp_out)
680 {
681  CopyMessageFlags cmflags =
683  CopyHeaderFlags chflags = CH_DECODE;
684 
685  if ((WithCrypto != 0) && (e->security & SEC_ENCRYPT))
686  {
687  /* make sure we have the user's passphrase before proceeding... */
689  return -1;
690  }
691 
694 
695  mutt_make_attribution(m, e, fp_out);
696 
697  if (!C_Header)
698  cmflags |= MUTT_CM_NOHEADER;
699  if (C_Weed)
700  {
701  chflags |= CH_WEED | CH_REORDER;
702  cmflags |= MUTT_CM_WEED;
703  }
704 
705  mutt_copy_message(fp_out, m, e, cmflags, chflags);
706 
707  mutt_make_post_indent(m, e, fp_out);
708 
709  return 0;
710 }
711 
721 static int default_to(struct AddressList *to, struct Envelope *env, SendFlags flags, int hmfupto)
722 {
723  char prompt[256];
724  const struct Address *from = TAILQ_FIRST(&env->from);
725  const struct Address *reply_to = TAILQ_FIRST(&env->reply_to);
726 
727  if (flags && !TAILQ_EMPTY(&env->mail_followup_to) && (hmfupto == MUTT_YES))
728  {
729  mutt_addrlist_copy(to, &env->mail_followup_to, true);
730  return 0;
731  }
732 
733  /* Exit now if we're setting up the default Cc list for list-reply
734  * (only set if Mail-Followup-To is present and honoured). */
735  if (flags & SEND_LIST_REPLY)
736  return 0;
737 
738  if (!C_ReplySelf && mutt_addr_is_user(from))
739  {
740  /* mail is from the user, assume replying to recipients */
741  mutt_addrlist_copy(to, &env->to, true);
742  }
743  else if (reply_to)
744  {
745  const bool from_is_reply_to = mutt_addr_cmp(from, reply_to);
746  const bool multiple_reply_to =
747  reply_to && TAILQ_NEXT(TAILQ_FIRST(&env->reply_to), entries);
748  if ((from_is_reply_to && !multiple_reply_to && !reply_to->personal) ||
749  (C_IgnoreListReplyTo && mutt_is_mail_list(reply_to) &&
750  (mutt_addrlist_search(reply_to, &env->to) ||
751  mutt_addrlist_search(reply_to, &env->cc))))
752  {
753  /* If the Reply-To: address is a mailing list, assume that it was
754  * put there by the mailing list, and use the From: address
755  *
756  * We also take the from header if our correspondent has a reply-to
757  * header which is identical to the electronic mail address given
758  * in his From header, and the reply-to has no display-name. */
759  mutt_addrlist_copy(to, &env->from, false);
760  }
761  else if (!(from_is_reply_to && !multiple_reply_to) && (C_ReplyTo != MUTT_YES))
762  {
763  /* There are quite a few mailing lists which set the Reply-To:
764  * header field to the list address, which makes it quite impossible
765  * to send a message to only the sender of the message. This
766  * provides a way to do that. */
767  /* L10N: Asks whether the user respects the reply-to header.
768  If she says no, neomutt will reply to the from header's address instead. */
769  snprintf(prompt, sizeof(prompt), _("Reply to %s%s?"), reply_to->mailbox,
770  multiple_reply_to ? ",..." : "");
771  switch (query_quadoption(C_ReplyTo, prompt))
772  {
773  case MUTT_YES:
774  mutt_addrlist_copy(to, &env->reply_to, false);
775  break;
776 
777  case MUTT_NO:
778  mutt_addrlist_copy(to, &env->from, false);
779  break;
780 
781  default:
782  return -1; /* abort */
783  }
784  }
785  else
786  mutt_addrlist_copy(to, &env->reply_to, false);
787  }
788  else
789  mutt_addrlist_copy(to, &env->from, false);
790 
791  return 0;
792 }
793 
802 int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags)
803 {
804  enum QuadOption hmfupto = MUTT_ABORT;
805  const struct Address *followup_to = TAILQ_FIRST(&in->mail_followup_to);
806 
807  if ((flags & (SEND_LIST_REPLY | SEND_GROUP_REPLY | SEND_GROUP_CHAT_REPLY)) && followup_to)
808  {
809  char prompt[256];
810  snprintf(prompt, sizeof(prompt), _("Follow-up to %s%s?"), followup_to->mailbox,
811  TAILQ_NEXT(TAILQ_FIRST(&in->mail_followup_to), entries) ? ",..." : "");
812 
813  hmfupto = query_quadoption(C_HonorFollowupTo, prompt);
814  if (hmfupto == MUTT_ABORT)
815  return -1;
816  }
817 
818  if (flags & SEND_LIST_REPLY)
819  {
820  add_mailing_lists(&out->to, &in->to, &in->cc);
821 
822  if (followup_to && (hmfupto == MUTT_YES) &&
823  (default_to(&out->cc, in, flags & SEND_LIST_REPLY, (hmfupto == MUTT_YES)) == MUTT_ABORT))
824  {
825  return -1; /* abort */
826  }
827  }
828  else if (flags & SEND_TO_SENDER)
829  {
830  mutt_addrlist_copy(&out->to, &in->from, false);
831  }
832  else
833  {
834  if (default_to(&out->to, in, flags & (SEND_GROUP_REPLY | SEND_GROUP_CHAT_REPLY),
835  (hmfupto == MUTT_YES)) == -1)
836  return -1; /* abort */
837 
838  if ((flags & (SEND_GROUP_REPLY | SEND_GROUP_CHAT_REPLY)) &&
839  (!followup_to || (hmfupto != MUTT_YES)))
840  {
841  /* if(!mutt_addr_is_user(in->to)) */
842  if (flags & SEND_GROUP_REPLY)
843  mutt_addrlist_copy(&out->cc, &in->to, true);
844  else
845  mutt_addrlist_copy(&out->to, &in->cc, true);
846  mutt_addrlist_copy(&out->cc, &in->cc, true);
847  }
848  }
849  return 0;
850 }
851 
857 static void add_references(struct ListHead *head, struct Envelope *env)
858 {
859  struct ListNode *np = NULL;
860 
861  struct ListHead *src = !STAILQ_EMPTY(&env->references) ? &env->references : &env->in_reply_to;
862  STAILQ_FOREACH(np, src, entries)
863  {
865  }
866 }
867 
873 static void add_message_id(struct ListHead *head, struct Envelope *env)
874 {
875  if (env->message_id)
876  {
878  }
879 }
880 
886 {
887  if (!C_Metoo)
888  {
889  /* the order is important here. do the CC: first so that if the
890  * the user is the only recipient, it ends up on the TO: field */
891  remove_user(&env->cc, TAILQ_EMPTY(&env->to));
892  remove_user(&env->to, TAILQ_EMPTY(&env->cc) || C_ReplySelf);
893  }
894 
895  /* the CC field can get cluttered, especially with lists */
896  mutt_addrlist_dedupe(&env->to);
897  mutt_addrlist_dedupe(&env->cc);
898  mutt_addrlist_remove_xrefs(&env->to, &env->cc);
899 
900  if (!TAILQ_EMPTY(&env->cc) && TAILQ_EMPTY(&env->to))
901  {
902  TAILQ_SWAP(&env->to, &env->cc, Address, entries);
903  }
904 }
905 
912 void mutt_make_forward_subject(struct Envelope *env, struct Mailbox *m, struct Email *e)
913 {
914  if (!env)
915  return;
916 
917  char buf[256];
918 
919  /* set the default subject for the message. */
920  mutt_make_string(buf, sizeof(buf), NONULL(C_ForwardFormat), NULL, m, e);
921  mutt_str_replace(&env->subject, buf);
922 }
923 
929 void mutt_make_misc_reply_headers(struct Envelope *env, struct Envelope *curenv)
930 {
931  if (!env || !curenv)
932  return;
933 
934  /* This takes precedence over a subject that might have
935  * been taken from a List-Post header. Is that correct? */
936  if (curenv->real_subj)
937  {
938  FREE(&env->subject);
939  env->subject = mutt_mem_malloc(mutt_str_strlen(curenv->real_subj) + 5);
940  sprintf(env->subject, "Re: %s", curenv->real_subj);
941  }
942  else if (!env->subject)
944 }
945 
951 void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv)
952 {
953  add_references(&env->references, curenv);
954  add_message_id(&env->references, curenv);
955  add_message_id(&env->in_reply_to, curenv);
956 
957 #ifdef USE_NNTP
958  if (OptNewsSend && C_XCommentTo && !TAILQ_EMPTY(&curenv->from))
960 #endif
961 }
962 
968 static void make_reference_headers(struct EmailList *el, struct Envelope *env)
969 {
970  if (!el || !env || STAILQ_EMPTY(el))
971  return;
972 
973  struct EmailNode *en = STAILQ_FIRST(el);
974  bool single = !STAILQ_NEXT(en, entries);
975 
976  if (!single)
977  {
978  STAILQ_FOREACH(en, el, entries)
979  {
981  }
982  }
983  else
985 
986  /* if there's more than entry in In-Reply-To (i.e. message has multiple
987  * parents), don't generate a References: header as it's discouraged by
988  * RFC2822, sect. 3.6.4 */
989  if (!single && !STAILQ_EMPTY(&env->in_reply_to) &&
990  STAILQ_NEXT(STAILQ_FIRST(&env->in_reply_to), entries))
991  {
992  mutt_list_free(&env->references);
993  }
994 }
995 
1005 static int envelope_defaults(struct Envelope *env, struct Mailbox *m,
1006  struct EmailList *el, SendFlags flags)
1007 {
1008  if (!el || STAILQ_EMPTY(el))
1009  return -1;
1010 
1011  struct EmailNode *en = STAILQ_FIRST(el);
1012  bool single = !STAILQ_NEXT(en, entries);
1013 
1014  struct Envelope *curenv = en->email->env;
1015  if (!curenv)
1016  return -1;
1017 
1018  if (flags & (SEND_REPLY | SEND_TO_SENDER))
1019  {
1020 #ifdef USE_NNTP
1021  if ((flags & SEND_NEWS))
1022  {
1023  /* in case followup set Newsgroups: with Followup-To: if it present */
1024  if (!env->newsgroups &&
1025  (mutt_str_strcasecmp(curenv->followup_to, "poster") != 0))
1026  {
1027  env->newsgroups = mutt_str_strdup(curenv->followup_to);
1028  }
1029  }
1030  else
1031 #endif
1032  if (!single)
1033  {
1034  STAILQ_FOREACH(en, el, entries)
1035  {
1036  if (mutt_fetch_recips(env, en->email->env, flags) == -1)
1037  return -1;
1038  }
1039  }
1040  else if (mutt_fetch_recips(env, curenv, flags) == -1)
1041  return -1;
1042 
1043  if ((flags & SEND_LIST_REPLY) && TAILQ_EMPTY(&env->to))
1044  {
1045  mutt_error(_("No mailing lists found"));
1046  return -1;
1047  }
1048 
1049  if (flags & SEND_REPLY)
1050  {
1051  mutt_make_misc_reply_headers(env, curenv);
1052  make_reference_headers(el, env);
1053  }
1054  }
1055  else if (flags & SEND_FORWARD)
1056  {
1057  mutt_make_forward_subject(env, m, en->email);
1058  if (C_ForwardReferences)
1059  make_reference_headers(el, env);
1060  }
1061 
1062  return 0;
1063 }
1064 
1075 static int generate_body(FILE *fp_tmp, struct Email *e, SendFlags flags,
1076  struct Mailbox *m, struct EmailList *el)
1077 {
1078  struct Body *tmp = NULL;
1079  struct EmailNode *en = NULL;
1080  bool single = true;
1081 
1082  if (el)
1083  en = STAILQ_FIRST(el);
1084  if (en)
1085  single = !STAILQ_NEXT(en, entries);
1086 
1087  /* An EmailList is required for replying and forwarding */
1088  if (!el && (flags & (SEND_REPLY | SEND_FORWARD)))
1089  return -1;
1090 
1091  if (flags & SEND_REPLY)
1092  {
1093  enum QuadOption ans =
1094  query_quadoption(C_Include, _("Include message in reply?"));
1095  if (ans == MUTT_ABORT)
1096  return -1;
1097 
1098  if (ans == MUTT_YES)
1099  {
1100  mutt_message(_("Including quoted message..."));
1101  if (!single)
1102  {
1103  STAILQ_FOREACH(en, el, entries)
1104  {
1105  if (include_reply(m, en->email, fp_tmp) == -1)
1106  {
1107  mutt_error(_("Could not include all requested messages"));
1108  return -1;
1109  }
1110  fputc('\n', fp_tmp);
1111  }
1112  }
1113  else
1114  include_reply(m, en->email, fp_tmp);
1115  }
1116  }
1117  else if (flags & SEND_FORWARD)
1118  {
1119  enum QuadOption ans =
1120  query_quadoption(C_MimeForward, _("Forward as attachment?"));
1121  if (ans == MUTT_YES)
1122  {
1123  struct Body *last = e->content;
1124 
1125  mutt_message(_("Preparing forwarded message..."));
1126 
1127  while (last && last->next)
1128  last = last->next;
1129 
1130  if (single)
1131  {
1132  tmp = mutt_make_message_attach(m, en->email, false);
1133  if (last)
1134  last->next = tmp;
1135  else
1136  e->content = tmp;
1137  }
1138  else
1139  {
1140  STAILQ_FOREACH(en, el, entries)
1141  {
1142  tmp = mutt_make_message_attach(m, en->email, false);
1143  if (last)
1144  {
1145  last->next = tmp;
1146  last = tmp;
1147  }
1148  else
1149  {
1150  last = tmp;
1151  e->content = tmp;
1152  }
1153  }
1154  }
1155  }
1156  else if (ans != MUTT_ABORT)
1157  {
1158  if (mutt_inline_forward(m, e, en->email, fp_tmp) != 0)
1159  return -1;
1160  }
1161  else
1162  return -1;
1163  }
1164  /* if (WithCrypto && (flags & SEND_KEY)) */
1165  else if (((WithCrypto & APPLICATION_PGP) != 0) && (flags & SEND_KEY))
1166  {
1167  struct Body *b = NULL;
1168 
1169  if (((WithCrypto & APPLICATION_PGP) != 0) && !(b = crypt_pgp_make_key_attachment()))
1170  {
1171  return -1;
1172  }
1173 
1174  b->next = e->content;
1175  e->content = b;
1176  }
1177 
1178  mutt_clear_error();
1179 
1180  return 0;
1181 }
1182 
1188 {
1189  /* Only generate the Mail-Followup-To if the user has requested it, and
1190  * it hasn't already been set */
1191 
1192  if (!C_FollowupTo)
1193  return;
1194 #ifdef USE_NNTP
1195  if (OptNewsSend)
1196  {
1197  if (!env->followup_to && env->newsgroups && (strrchr(env->newsgroups, ',')))
1198  env->followup_to = mutt_str_strdup(env->newsgroups);
1199  return;
1200  }
1201 #endif
1202 
1203  if (TAILQ_EMPTY(&env->mail_followup_to))
1204  {
1205  if (mutt_is_list_recipient(false, env))
1206  {
1207  /* this message goes to known mailing lists, so create a proper
1208  * mail-followup-to header */
1209 
1210  mutt_addrlist_copy(&env->mail_followup_to, &env->to, false);
1211  mutt_addrlist_copy(&env->mail_followup_to, &env->cc, true);
1212  }
1213 
1214  /* remove ourselves from the mail-followup-to header */
1215  remove_user(&env->mail_followup_to, false);
1216 
1217  /* If we are not subscribed to any of the lists in question, re-add
1218  * ourselves to the mail-followup-to header. The mail-followup-to header
1219  * generated is a no-op with group-reply, but makes sure list-reply has the
1220  * desired effect. */
1221 
1222  if (!TAILQ_EMPTY(&env->mail_followup_to) &&
1223  !mutt_is_subscribed_list_recipient(false, env))
1224  {
1225  struct AddressList *al = NULL;
1226  if (!TAILQ_EMPTY(&env->reply_to))
1227  al = &env->reply_to;
1228  else if (!TAILQ_EMPTY(&env->from))
1229  al = &env->from;
1230 
1231  if (al)
1232  {
1233  struct Address *a = NULL;
1234  TAILQ_FOREACH_REVERSE(a, al, AddressList, entries)
1235  {
1237  }
1238  }
1239  else
1240  {
1242  }
1243  }
1244 
1246  }
1247 }
1248 
1258 static void set_reverse_name(struct AddressList *al, struct Envelope *env)
1259 {
1260  struct Address *a = NULL;
1261  if (TAILQ_EMPTY(al))
1262  {
1263  TAILQ_FOREACH(a, &env->to, entries)
1264  {
1265  if (mutt_addr_is_user(a))
1266  {
1268  break;
1269  }
1270  }
1271  }
1272 
1273  if (TAILQ_EMPTY(al))
1274  {
1275  TAILQ_FOREACH(a, &env->cc, entries)
1276  {
1277  if (mutt_addr_is_user(a))
1278  {
1280  break;
1281  }
1282  }
1283  }
1284 
1285  if (TAILQ_EMPTY(al))
1286  {
1287  struct Address *from = TAILQ_FIRST(&env->from);
1288  if (from && mutt_addr_is_user(from))
1289  {
1291  }
1292  }
1293 
1294  if (!TAILQ_EMPTY(al))
1295  {
1296  /* when $reverse_realname is not set, clear the personal name so that it
1297  * may be set via a reply- or send-hook. */
1298  if (!C_ReverseRealname)
1299  FREE(&TAILQ_FIRST(al)->personal);
1300  }
1301 }
1302 
1308 {
1309  /* Note: We let $from override $realname here.
1310  * Is this the right thing to do?
1311  */
1312 
1313  if (C_From)
1314  {
1315  return mutt_addr_copy(C_From);
1316  }
1317  else if (C_UseDomain)
1318  {
1319  struct Address *addr = mutt_addr_new();
1320  mutt_str_asprintf(&addr->mailbox, "%s@%s", NONULL(Username), NONULL(mutt_fqdn(true)));
1321  return addr;
1322  }
1323  else
1324  {
1325  return mutt_addr_create(NULL, Username);
1326  }
1327 }
1328 
1335 static int send_message(struct Email *e)
1336 {
1337  char tempfile[PATH_MAX];
1338  int i;
1339 #ifdef USE_SMTP
1340  short old_write_bcc;
1341 #endif
1342 
1343  /* Write out the message in MIME form. */
1344  mutt_mktemp(tempfile, sizeof(tempfile));
1345  FILE *fp_tmp = mutt_file_fopen(tempfile, "w");
1346  if (!fp_tmp)
1347  return -1;
1348 
1349 #ifdef USE_SMTP
1350  old_write_bcc = C_WriteBcc;
1351  if (C_SmtpUrl)
1352  C_WriteBcc = false;
1353 #endif
1354 #ifdef MIXMASTER
1356  !STAILQ_EMPTY(&e->chain),
1358 #endif
1359 #ifndef MIXMASTER
1362 #endif
1363 #ifdef USE_SMTP
1364  if (old_write_bcc)
1365  C_WriteBcc = true;
1366 #endif
1367 
1368  fputc('\n', fp_tmp); /* tie off the header. */
1369 
1370  if ((mutt_write_mime_body(e->content, fp_tmp) == -1))
1371  {
1372  mutt_file_fclose(&fp_tmp);
1373  unlink(tempfile);
1374  return -1;
1375  }
1376 
1377  if (fclose(fp_tmp) != 0)
1378  {
1379  mutt_perror(tempfile);
1380  unlink(tempfile);
1381  return -1;
1382  }
1383 
1384 #ifdef MIXMASTER
1385  if (!STAILQ_EMPTY(&e->chain))
1386  return mix_send_message(&e->chain, tempfile);
1387 #endif
1388 
1389 #ifdef USE_SMTP
1390 #ifdef USE_NNTP
1391  if (!OptNewsSend)
1392 #endif
1393  if (C_SmtpUrl)
1394  {
1395  return mutt_smtp_send(&e->env->from, &e->env->to, &e->env->cc, &e->env->bcc,
1396  tempfile, (e->content->encoding == ENC_8BIT));
1397  }
1398 #endif /* USE_SMTP */
1399 
1400  i = mutt_invoke_sendmail(&e->env->from, &e->env->to, &e->env->cc, &e->env->bcc,
1401  tempfile, (e->content->encoding == ENC_8BIT));
1402  return i;
1403 }
1404 
1410 void mutt_encode_descriptions(struct Body *b, bool recurse)
1411 {
1412  for (struct Body *t = b; t; t = t->next)
1413  {
1414  if (t->description)
1415  {
1416  rfc2047_encode(&t->description, NULL, sizeof("Content-Description:"), C_SendCharset);
1417  }
1418  if (recurse && t->parts)
1419  mutt_encode_descriptions(t->parts, recurse);
1420  }
1421 }
1422 
1427 static void decode_descriptions(struct Body *b)
1428 {
1429  for (struct Body *t = b; t; t = t->next)
1430  {
1431  if (t->description)
1432  {
1433  rfc2047_decode(&t->description);
1434  }
1435  if (t->parts)
1436  decode_descriptions(t->parts);
1437  }
1438 }
1439 
1444 static void fix_end_of_file(const char *data)
1445 {
1446  FILE *fp = mutt_file_fopen(data, "a+");
1447  if (!fp)
1448  return;
1449  if (fseek(fp, -1, SEEK_END) >= 0)
1450  {
1451  int c = fgetc(fp);
1452  if (c != '\n')
1453  fputc('\n', fp);
1454  }
1455  mutt_file_fclose(&fp);
1456 }
1457 
1467 int mutt_resend_message(FILE *fp, struct Context *ctx, struct Email *e_cur)
1468 {
1469  struct Email *e_new = email_new();
1470 
1471  if (mutt_prepare_template(fp, ctx->mailbox, e_new, e_cur, true) < 0)
1472  {
1473  email_free(&e_new);
1474  return -1;
1475  }
1476 
1477  if (WithCrypto)
1478  {
1479  /* mutt_prepare_template doesn't always flip on an application bit.
1480  * so fix that here */
1481  if (!(e_new->security & (APPLICATION_SMIME | APPLICATION_PGP)))
1482  {
1483  if (((WithCrypto & APPLICATION_SMIME) != 0) && C_SmimeIsDefault)
1484  e_new->security |= APPLICATION_SMIME;
1485  else if (WithCrypto & APPLICATION_PGP)
1486  e_new->security |= APPLICATION_PGP;
1487  else
1488  e_new->security |= APPLICATION_SMIME;
1489  }
1490 
1492  {
1493  e_new->security |= SEC_OPPENCRYPT;
1495  }
1496  }
1497 
1498  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
1499  el_add_email(&el, e_cur);
1500  int rc = ci_send_message(SEND_RESEND, e_new, NULL, ctx, &el);
1501  emaillist_clear(&el);
1502 
1503  return rc;
1504 }
1505 
1513 static bool is_reply(struct Email *reply, struct Email *orig)
1514 {
1515  if (!reply || !reply->env || !orig || !orig->env)
1516  return false;
1517  return mutt_list_find(&orig->env->references, reply->env->message_id) ||
1518  mutt_list_find(&orig->env->in_reply_to, reply->env->message_id);
1519 }
1520 
1531 static bool search_attach_keyword(char *filename)
1532 {
1533  /* Search for the regex in C_AbortNoattachRegex within a file */
1534  if (!C_AbortNoattachRegex || !C_AbortNoattachRegex->regex || !C_QuoteRegex ||
1535  !C_QuoteRegex->regex)
1536  {
1537  return false;
1538  }
1539 
1540  FILE *fp_att = mutt_file_fopen(filename, "r");
1541  if (!fp_att)
1542  return false;
1543 
1544  char *inputline = mutt_mem_malloc(1024);
1545  bool found = false;
1546  while (!feof(fp_att))
1547  {
1548  fgets(inputline, 1024, fp_att);
1549  if (!mutt_is_quote_line(inputline, NULL) &&
1550  mutt_regex_match(C_AbortNoattachRegex, inputline))
1551  {
1552  found = true;
1553  break;
1554  }
1555  }
1556  FREE(&inputline);
1557  mutt_file_fclose(&fp_att);
1558  return found;
1559 }
1560 
1573 static int save_fcc(struct Email *e, char *fcc, size_t fcc_len, struct Body *clear_content,
1574  char *pgpkeylist, SendFlags flags, char **finalpath)
1575 {
1576  int rc = 0;
1577  struct Body *save_content = NULL;
1578 
1579  mutt_expand_path(fcc, fcc_len);
1580 
1581  /* Don't save a copy when we are in batch-mode, and the FCC
1582  * folder is on an IMAP server: This would involve possibly lots
1583  * of user interaction, which is not available in batch mode.
1584  *
1585  * Note: A patch to fix the problems with the use of IMAP servers
1586  * from non-curses mode is available from Brendan Cully. However,
1587  * I'd like to think a bit more about this before including it. */
1588 
1589 #ifdef USE_IMAP
1590  if ((flags & SEND_BATCH) && (fcc[0] != '\0') && (imap_path_probe(fcc, NULL) == MUTT_IMAP))
1591  {
1592  fcc[0] = '\0';
1593  mutt_error(_("Fcc to an IMAP mailbox is not supported in batch mode"));
1594  return rc;
1595  }
1596 #endif
1597 
1598  if (!(*fcc && mutt_str_strcmp("/dev/null", fcc)))
1599  return rc;
1600 
1601  struct Body *tmpbody = e->content;
1602  struct Body *save_sig = NULL;
1603  struct Body *save_parts = NULL;
1604 
1605  /* Before sending, we don't allow message manipulation because it
1606  * will break message signatures. This is especially complicated by
1607  * Protected Headers. */
1608  if (!C_FccBeforeSend)
1609  {
1610  if ((WithCrypto != 0) && (e->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT)) && C_FccClear)
1611  {
1612  e->content = clear_content;
1615  }
1616 
1617  /* check to see if the user wants copies of all attachments */
1618  if (e->content->type == TYPE_MULTIPART)
1619  {
1620  if ((WithCrypto != 0) && (e->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT)) &&
1621  ((mutt_str_strcmp(e->content->subtype, "encrypted") == 0) ||
1622  (mutt_str_strcmp(e->content->subtype, "signed") == 0)))
1623  {
1624  if ((clear_content->type == TYPE_MULTIPART) &&
1625  (query_quadoption(C_FccAttach, _("Save attachments in Fcc?")) == MUTT_NO))
1626  {
1627  if (!(e->security & SEC_ENCRYPT) && (e->security & SEC_SIGN))
1628  {
1629  /* save initial signature and attachments */
1630  save_sig = e->content->parts->next;
1631  save_parts = clear_content->parts->next;
1632  }
1633 
1634  /* this means writing only the main part */
1635  e->content = clear_content->parts;
1636 
1637  if (mutt_protect(e, pgpkeylist, false) == -1)
1638  {
1639  /* we can't do much about it at this point, so
1640  * fallback to saving the whole thing to fcc */
1641  e->content = tmpbody;
1642  save_sig = NULL;
1643  goto full_fcc;
1644  }
1645 
1646  save_content = e->content;
1647  }
1648  }
1649  else
1650  {
1651  if (query_quadoption(C_FccAttach, _("Save attachments in Fcc?")) == MUTT_NO)
1652  e->content = e->content->parts;
1653  }
1654  }
1655  }
1656 
1657 full_fcc:
1658  if (e->content)
1659  {
1660  /* update received time so that when storing to a mbox-style folder
1661  * the From_ line contains the current time instead of when the
1662  * message was first postponed. */
1663  e->received = mutt_date_epoch();
1664  rc = mutt_write_multiple_fcc(fcc, e, NULL, false, NULL, finalpath);
1665  while (rc && !(flags & SEND_BATCH))
1666  {
1667  mutt_clear_error();
1668  int choice = mutt_multi_choice(
1669  /* L10N: Called when saving to $record or Fcc failed after sending.
1670  (r)etry tries the same mailbox again.
1671  alternate (m)ailbox prompts for a different mailbox to try.
1672  (s)kip aborts saving. */
1673  _("Fcc failed. (r)etry, alternate (m)ailbox, or (s)kip?"),
1674  /* L10N: These correspond to the "Fcc failed" multi-choice prompt
1675  (r)etry, alternate (m)ailbox, or (s)kip.
1676  Any similarity to famous leaders of the FSF is coincidental. */
1677  _("rms"));
1678  switch (choice)
1679  {
1680  case 2: /* alternate (m)ailbox */
1681  /* L10N: This is the prompt to enter an "alternate (m)ailbox" when the
1682  initial Fcc fails. */
1683  rc = mutt_enter_fname(_("Fcc mailbox"), fcc, fcc_len, true);
1684  if ((rc == -1) || (fcc[0] == '\0'))
1685  {
1686  rc = 0;
1687  break;
1688  }
1689  /* fall through */
1690 
1691  case 1: /* (r)etry */
1692  rc = mutt_write_multiple_fcc(fcc, e, NULL, false, NULL, finalpath);
1693  break;
1694 
1695  case -1: /* abort */
1696  case 3: /* (s)kip */
1697  rc = 0;
1698  break;
1699  }
1700  }
1701  }
1702 
1703  if (!C_FccBeforeSend)
1704  {
1705  e->content = tmpbody;
1706 
1707  if ((WithCrypto != 0) && save_sig)
1708  {
1709  /* cleanup the second signature structures */
1710  if (save_content->parts)
1711  {
1712  mutt_body_free(&save_content->parts->next);
1713  save_content->parts = NULL;
1714  }
1715  mutt_body_free(&save_content);
1716 
1717  /* restore old signature and attachments */
1718  e->content->parts->next = save_sig;
1719  e->content->parts->parts->next = save_parts;
1720  }
1721  else if ((WithCrypto != 0) && save_content)
1722  {
1723  /* destroy the new encrypted body. */
1724  mutt_body_free(&save_content);
1725  }
1726  }
1727 
1728  return 0;
1729 }
1730 
1740 static int postpone_message(struct Email *e_post, struct Email *e_cur, char *fcc, SendFlags flags)
1741 {
1742  char *pgpkeylist = NULL;
1743  char *encrypt_as = NULL;
1744  struct Body *clear_content = NULL;
1745 
1746  if (!C_Postponed)
1747  {
1748  mutt_error(_("Can't postpone. $postponed is unset"));
1749  return -1;
1750  }
1751 
1752  if (e_post->content->next)
1753  e_post->content = mutt_make_multipart(e_post->content);
1754 
1755  mutt_encode_descriptions(e_post->content, true);
1756 
1757  if ((WithCrypto != 0) && C_PostponeEncrypt &&
1758  (e_post->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)))
1759  {
1760  if (((WithCrypto & APPLICATION_PGP) != 0) && (e_post->security & APPLICATION_PGP))
1761  encrypt_as = C_PgpDefaultKey;
1762  else if (((WithCrypto & APPLICATION_SMIME) != 0) && (e_post->security & APPLICATION_SMIME))
1763  encrypt_as = C_SmimeDefaultKey;
1764  if (!encrypt_as)
1765  encrypt_as = C_PostponeEncryptAs;
1766 
1767 #ifdef USE_AUTOCRYPT
1768  if (e_post->security & SEC_AUTOCRYPT)
1769  {
1771  return -1;
1772  encrypt_as = AutocryptDefaultKey;
1773  }
1774 #endif
1775 
1776  if (encrypt_as)
1777  {
1778  pgpkeylist = mutt_str_strdup(encrypt_as);
1779  clear_content = e_post->content;
1780  if (mutt_protect(e_post, pgpkeylist, true) == -1)
1781  {
1782  FREE(&pgpkeylist);
1783  e_post->content = mutt_remove_multipart(e_post->content);
1784  decode_descriptions(e_post->content);
1785  return -1;
1786  }
1787 
1788  FREE(&pgpkeylist);
1789 
1790  mutt_encode_descriptions(e_post->content, false);
1791  }
1792  }
1793 
1794  /* make sure the message is written to the right part of a maildir
1795  * postponed folder. */
1796  e_post->read = false;
1797  e_post->old = false;
1798 
1799  mutt_prepare_envelope(e_post->env, false);
1800  mutt_env_to_intl(e_post->env, NULL, NULL); /* Handle bad IDNAs the next time. */
1801 
1802  if (mutt_write_fcc(NONULL(C_Postponed), e_post,
1803  (e_cur && (flags & SEND_REPLY)) ? e_cur->env->message_id : NULL,
1804  true, fcc, NULL) < 0)
1805  {
1806  if (clear_content)
1807  {
1808  mutt_body_free(&e_post->content);
1809  e_post->content = clear_content;
1810  }
1811  mutt_env_free(&e_post->content->mime_headers); /* protected headers */
1812  e_post->content = mutt_remove_multipart(e_post->content);
1813  decode_descriptions(e_post->content);
1814  mutt_unprepare_envelope(e_post->env);
1815  return -1;
1816  }
1817 
1819 
1820  if (clear_content)
1821  mutt_body_free(&clear_content);
1822 
1823  return 0;
1824 }
1825 
1837 int ci_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile,
1838  struct Context *ctx, struct EmailList *el)
1839 {
1840  char buf[1024];
1841  char fcc[PATH_MAX] = { 0 }; /* where to copy this message */
1842  FILE *fp_tmp = NULL;
1843  struct Body *pbody = NULL;
1844  int i;
1845  bool free_clear_content = false;
1846 
1847  struct Body *clear_content = NULL;
1848  char *pgpkeylist = NULL;
1849  /* save current value of "pgp_sign_as" and "smime_default_key" */
1850  char *pgp_signas = NULL;
1851  char *smime_signas = NULL;
1852  const char *tag = NULL;
1853  char *err = NULL;
1854  char *ctype = NULL;
1855  char *finalpath = NULL;
1856  struct EmailNode *en = NULL;
1857  struct Email *e_cur = NULL;
1858 
1859  if (el)
1860  en = STAILQ_FIRST(el);
1861  if (en)
1862  e_cur = STAILQ_NEXT(en, entries) ? NULL : en->email;
1863 
1864  int rc = -1;
1865 
1866 #ifdef USE_NNTP
1867  if (flags & SEND_NEWS)
1868  OptNewsSend = true;
1869  else
1870  OptNewsSend = false;
1871 #endif
1872 
1873  if (!flags && !e_templ && (C_Recall != MUTT_NO) &&
1874  mutt_num_postponed(ctx ? ctx->mailbox : NULL, true))
1875  {
1876  /* If the user is composing a new message, check to see if there
1877  * are any postponed messages first. */
1878  enum QuadOption ans =
1879  query_quadoption(C_Recall, _("Recall postponed message?"));
1880  if (ans == MUTT_ABORT)
1881  return rc;
1882 
1883  if (ans == MUTT_YES)
1884  flags |= SEND_POSTPONED;
1885  }
1886 
1887  if (flags & SEND_POSTPONED)
1888  {
1890  pgp_signas = mutt_str_strdup(C_PgpSignAs);
1892  smime_signas = mutt_str_strdup(C_SmimeSignAs);
1893  }
1894 
1895  /* Delay expansion of aliases until absolutely necessary--shouldn't
1896  * be necessary unless we are prompting the user or about to execute a
1897  * send-hook. */
1898 
1899  if (!e_templ)
1900  {
1901  e_templ = email_new();
1902 
1903  if (flags == SEND_POSTPONED)
1904  {
1905  rc = mutt_get_postponed(ctx, e_templ, &e_cur, fcc, sizeof(fcc));
1906  if (rc < 0)
1907  {
1908  flags = SEND_POSTPONED;
1909  goto cleanup;
1910  }
1911  flags = rc;
1912 #ifdef USE_NNTP
1913  /* If postponed message is a news article, it have
1914  * a "Newsgroups:" header line, then set appropriate flag. */
1915  if (e_templ->env->newsgroups)
1916  {
1917  flags |= SEND_NEWS;
1918  OptNewsSend = true;
1919  }
1920  else
1921  {
1922  flags &= ~SEND_NEWS;
1923  OptNewsSend = false;
1924  }
1925 #endif
1926  }
1927 
1928  if (flags & (SEND_POSTPONED | SEND_RESEND))
1929  {
1930  fp_tmp = mutt_file_fopen(e_templ->content->filename, "a+");
1931  if (!fp_tmp)
1932  {
1933  mutt_perror(e_templ->content->filename);
1934  goto cleanup;
1935  }
1936  }
1937 
1938  if (!e_templ->env)
1939  e_templ->env = mutt_env_new();
1940  }
1941 
1942  /* Parse and use an eventual list-post header */
1943  if ((flags & SEND_LIST_REPLY) && e_cur && e_cur->env && e_cur->env->list_post)
1944  {
1945  /* Use any list-post header as a template */
1946  mutt_parse_mailto(e_templ->env, NULL, e_cur->env->list_post);
1947  /* We don't let them set the sender's address. */
1948  mutt_addrlist_clear(&e_templ->env->from);
1949  }
1950 
1951  if (!(flags & (SEND_KEY | SEND_POSTPONED | SEND_RESEND)))
1952  {
1953  /* When SEND_DRAFT_FILE is set, the caller has already
1954  * created the "parent" body structure. */
1955  if (!(flags & SEND_DRAFT_FILE))
1956  {
1957  pbody = mutt_body_new();
1958  pbody->next = e_templ->content; /* don't kill command-line attachments */
1959  e_templ->content = pbody;
1960 
1961  ctype = mutt_str_strdup(C_ContentType);
1962  if (!ctype)
1963  ctype = mutt_str_strdup("text/plain");
1964  mutt_parse_content_type(ctype, e_templ->content);
1965  FREE(&ctype);
1966  e_templ->content->unlink = true;
1967  e_templ->content->use_disp = false;
1968  e_templ->content->disposition = DISP_INLINE;
1969 
1970  if (!tempfile)
1971  {
1972  mutt_mktemp(buf, sizeof(buf));
1973  fp_tmp = mutt_file_fopen(buf, "w+");
1974  e_templ->content->filename = mutt_str_strdup(buf);
1975  }
1976  else
1977  {
1978  fp_tmp = mutt_file_fopen(tempfile, "a+");
1979  e_templ->content->filename = mutt_str_strdup(tempfile);
1980  }
1981  }
1982  else
1983  fp_tmp = mutt_file_fopen(e_templ->content->filename, "a+");
1984 
1985  if (!fp_tmp)
1986  {
1987  mutt_debug(LL_DEBUG1, "can't create tempfile %s (errno=%d)\n",
1988  e_templ->content->filename, errno);
1989  mutt_perror(e_templ->content->filename);
1990  goto cleanup;
1991  }
1992  }
1993 
1994  /* this is handled here so that the user can match ~f in send-hook */
1995  if (e_cur && C_ReverseName && !(flags & (SEND_POSTPONED | SEND_RESEND)))
1996  {
1997  /* We shouldn't have to worry about alias expansion here since we are
1998  * either replying to a real or postponed message, therefore no aliases
1999  * should exist since the user has not had the opportunity to add
2000  * addresses to the list. We just have to ensure the postponed messages
2001  * have their aliases expanded. */
2002 
2003  if (!TAILQ_EMPTY(&e_templ->env->from))
2004  {
2005  mutt_debug(LL_DEBUG5, "e_templ->env->from before set_reverse_name: %s\n",
2006  TAILQ_FIRST(&e_templ->env->from)->mailbox);
2007  mutt_addrlist_clear(&e_templ->env->from);
2008  }
2009  set_reverse_name(&e_templ->env->from, e_cur->env);
2010  }
2011  if (e_cur && C_ReplyWithXorig && !(flags & (SEND_POSTPONED | SEND_RESEND | SEND_FORWARD)))
2012  {
2013  /* We shouldn't have to worry about freeing 'e_templ->env->from' before
2014  * setting it here since this code will only execute when doing some
2015  * sort of reply. The pointer will only be set when using the -H command
2016  * line option.
2017  *
2018  * If there is already a from address recorded in 'e_templ->env->from',
2019  * then it theoretically comes from C_ReverseName handling, and we don't use
2020  * the 'X-Orig-To header'. */
2021  if (!TAILQ_EMPTY(&e_cur->env->x_original_to) && TAILQ_EMPTY(&e_templ->env->from))
2022  {
2023  mutt_addrlist_copy(&e_templ->env->from, &e_cur->env->x_original_to, false);
2024  mutt_debug(LL_DEBUG5, "e_templ->env->from extracted from X-Original-To: header: %s\n",
2025  TAILQ_FIRST(&e_templ->env->from)->mailbox);
2026  }
2027  }
2028 
2029  if (!(flags & (SEND_POSTPONED | SEND_RESEND)) &&
2030  !((flags & SEND_DRAFT_FILE) && C_ResumeDraftFiles))
2031  {
2032  if ((flags & (SEND_REPLY | SEND_FORWARD | SEND_TO_SENDER)) && ctx &&
2033  (envelope_defaults(e_templ->env, ctx->mailbox, el, flags) == -1))
2034  {
2035  goto cleanup;
2036  }
2037 
2038  if (C_Hdrs)
2039  process_user_recips(e_templ->env);
2040 
2041  /* Expand aliases and remove duplicates/crossrefs */
2042  mutt_expand_aliases_env(e_templ->env);
2043 
2044  if (flags & SEND_REPLY)
2045  mutt_fix_reply_recipients(e_templ->env);
2046 
2047 #ifdef USE_NNTP
2048  if ((flags & SEND_NEWS) && ctx && (ctx->mailbox->magic == MUTT_NNTP) &&
2049  !e_templ->env->newsgroups)
2050  {
2051  e_templ->env->newsgroups =
2052  mutt_str_strdup(((struct NntpMboxData *) ctx->mailbox->mdata)->group);
2053  }
2054 #endif
2055 
2056  if (!(flags & (SEND_MAILX | SEND_BATCH)) &&
2057  !(C_Autoedit && C_EditHeaders) && !((flags & SEND_REPLY) && C_FastReply))
2058  {
2059  if (edit_envelope(e_templ->env, flags) == -1)
2060  goto cleanup;
2061  }
2062 
2063  /* the from address must be set here regardless of whether or not
2064  * $use_from is set so that the '~P' (from you) operator in send-hook
2065  * patterns will work. if $use_from is unset, the from address is killed
2066  * after send-hooks are evaluated */
2067 
2068  const bool killfrom = TAILQ_EMPTY(&e_templ->env->from);
2069  if (killfrom)
2070  {
2072  }
2073 
2074  if ((flags & SEND_REPLY) && e_cur)
2075  {
2076  /* change setting based upon message we are replying to */
2077  mutt_message_hook(ctx ? ctx->mailbox : NULL, e_cur, MUTT_REPLY_HOOK);
2078 
2079  /* set the replied flag for the message we are generating so that the
2080  * user can use ~Q in a send-hook to know when reply-hook's are also
2081  * being used. */
2082  e_templ->replied = true;
2083  }
2084 
2085  /* change settings based upon recipients */
2086 
2087  mutt_message_hook(NULL, e_templ, MUTT_SEND_HOOK);
2088 
2089  /* Unset the replied flag from the message we are composing since it is
2090  * no longer required. This is done here because the FCC'd copy of
2091  * this message was erroneously get the 'R'eplied flag when stored in
2092  * a maildir-style mailbox. */
2093  e_templ->replied = false;
2094 
2095  if (!(flags & SEND_KEY))
2096  {
2097  if (C_TextFlowed && (e_templ->content->type == TYPE_TEXT) &&
2098  (mutt_str_strcasecmp(e_templ->content->subtype, "plain") == 0))
2099  {
2100  mutt_param_set(&e_templ->content->parameter, "format", "flowed");
2101  }
2102  }
2103 
2104  /* $use_from and/or $from might have changed in a send-hook */
2105  if (killfrom)
2106  {
2107  mutt_addrlist_clear(&e_templ->env->from);
2108  if (C_UseFrom && !(flags & (SEND_POSTPONED | SEND_RESEND)))
2110  }
2111 
2112  if (C_Hdrs)
2113  process_user_header(e_templ->env);
2114 
2115  if (flags & SEND_BATCH)
2116  mutt_file_copy_stream(stdin, fp_tmp);
2117 
2118  if (C_SigOnTop && !(flags & (SEND_MAILX | SEND_KEY | SEND_BATCH)) &&
2119  C_Editor && (mutt_str_strcmp(C_Editor, "builtin") != 0))
2120  {
2121  append_signature(fp_tmp);
2122  }
2123 
2124  /* include replies/forwarded messages, unless we are given a template */
2125  if (!tempfile && (ctx || !(flags & (SEND_REPLY | SEND_FORWARD))) &&
2126  (generate_body(fp_tmp, e_templ, flags, ctx ? ctx->mailbox : NULL, el) == -1))
2127  {
2128  goto cleanup;
2129  }
2130 
2131  if (!C_SigOnTop && !(flags & (SEND_MAILX | SEND_KEY | SEND_BATCH)) &&
2132  C_Editor && (mutt_str_strcmp(C_Editor, "builtin") != 0))
2133  {
2134  append_signature(fp_tmp);
2135  }
2136  }
2137 
2138  /* This hook is even called for postponed messages, and can, e.g., be
2139  * used for setting the editor, the sendmail path, or the
2140  * envelope sender. */
2141  mutt_message_hook(NULL, e_templ, MUTT_SEND2_HOOK);
2142 
2143  /* wait until now to set the real name portion of our return address so
2144  * that $realname can be set in a send-hook */
2145  {
2146  struct Address *from = TAILQ_FIRST(&e_templ->env->from);
2147  if (from && !from->personal && !(flags & (SEND_RESEND | SEND_POSTPONED)))
2149  }
2150 
2151  if (!(((WithCrypto & APPLICATION_PGP) != 0) && (flags & SEND_KEY)))
2152  mutt_file_fclose(&fp_tmp);
2153 
2154  if (flags & SEND_MAILX)
2155  {
2156  if (mutt_builtin_editor(e_templ->content->filename, e_templ, e_cur) == -1)
2157  goto cleanup;
2158  }
2159  else if (!(flags & SEND_BATCH))
2160  {
2161  struct stat st;
2162  time_t mtime = mutt_file_decrease_mtime(e_templ->content->filename, NULL);
2163 
2164  mutt_update_encoding(e_templ->content);
2165 
2166  /* Select whether or not the user's editor should be called now. We
2167  * don't want to do this when:
2168  * 1) we are sending a key/cert
2169  * 2) we are forwarding a message and the user doesn't want to edit it.
2170  * This is controlled by the quadoption $forward_edit. However, if
2171  * both $edit_headers and $autoedit are set, we want to ignore the
2172  * setting of $forward_edit because the user probably needs to add the
2173  * recipients. */
2174  if (!(flags & SEND_KEY) &&
2175  (((flags & SEND_FORWARD) == 0) || (C_EditHeaders && C_Autoedit) ||
2176  (query_quadoption(C_ForwardEdit, _("Edit forwarded message?")) == MUTT_YES)))
2177  {
2178  /* If the this isn't a text message, look for a mailcap edit command */
2179  if (mutt_needs_mailcap(e_templ->content))
2180  {
2181  if (!mutt_edit_attachment(e_templ->content))
2182  goto cleanup;
2183  }
2184  else if (!C_Editor || (mutt_str_strcmp("builtin", C_Editor) == 0))
2185  mutt_builtin_editor(e_templ->content->filename, e_templ, e_cur);
2186  else if (C_EditHeaders)
2187  {
2188  mutt_env_to_local(e_templ->env);
2189  mutt_edit_headers(C_Editor, e_templ->content->filename, e_templ, fcc, sizeof(fcc));
2190  mutt_env_to_intl(e_templ->env, NULL, NULL);
2191  }
2192  else
2193  {
2195  if (stat(e_templ->content->filename, &st) == 0)
2196  {
2197  if (mtime != st.st_mtime)
2198  fix_end_of_file(e_templ->content->filename);
2199  }
2200  else
2201  mutt_perror(e_templ->content->filename);
2202  }
2203 
2204  /* If using format=flowed, perform space stuffing. Avoid stuffing when
2205  * recalling a postponed message where the stuffing was already
2206  * performed. If it has already been performed, the format=flowed
2207  * parameter will be present. */
2208  if (C_TextFlowed && (e_templ->content->type == TYPE_TEXT) &&
2209  (mutt_str_strcasecmp("plain", e_templ->content->subtype) == 0))
2210  {
2211  char *p = mutt_param_get(&e_templ->content->parameter, "format");
2212  if (mutt_str_strcasecmp("flowed", p) != 0)
2213  rfc3676_space_stuff(e_templ);
2214  }
2215 
2216  mutt_message_hook(NULL, e_templ, MUTT_SEND2_HOOK);
2217  }
2218 
2219  if (!(flags & (SEND_POSTPONED | SEND_FORWARD | SEND_KEY | SEND_RESEND | SEND_DRAFT_FILE)))
2220  {
2221  if (stat(e_templ->content->filename, &st) == 0)
2222  {
2223  /* if the file was not modified, bail out now */
2224  if ((mtime == st.st_mtime) && !e_templ->content->next &&
2226  _("Abort unmodified message?")) == MUTT_YES))
2227  {
2228  mutt_message(_("Aborted unmodified message"));
2229  goto cleanup;
2230  }
2231  }
2232  else
2233  mutt_perror(e_templ->content->filename);
2234  }
2235  }
2236 
2237  /* Set the message security unless:
2238  * 1) crypto support is not enabled (WithCrypto==0)
2239  * 2) pgp: header field was present during message editing with $edit_headers (e_templ->security != 0)
2240  * 3) we are resending a message
2241  * 4) we are recalling a postponed message (don't override the user's saved settings)
2242  * 5) we are in mailx mode
2243  * 6) we are in batch mode
2244  *
2245  * This is done after allowing the user to edit the message so that security
2246  * settings can be configured with send2-hook and $edit_headers. */
2247  if ((WithCrypto != 0) && (e_templ->security == 0) &&
2248  !(flags & (SEND_BATCH | SEND_MAILX | SEND_POSTPONED | SEND_RESEND)))
2249  {
2250  if (
2251 #ifdef USE_AUTOCRYPT
2253 #else
2254  0
2255 #endif
2256  && e_cur && (e_cur->security & SEC_AUTOCRYPT))
2257  {
2259  }
2260  else
2261  {
2262  if (C_CryptAutosign)
2263  e_templ->security |= SEC_SIGN;
2264  if (C_CryptAutoencrypt)
2265  e_templ->security |= SEC_ENCRYPT;
2266  if (C_CryptReplyencrypt && e_cur && (e_cur->security & SEC_ENCRYPT))
2267  e_templ->security |= SEC_ENCRYPT;
2268  if (C_CryptReplysign && e_cur && (e_cur->security & SEC_SIGN))
2269  e_templ->security |= SEC_SIGN;
2270  if (C_CryptReplysignencrypted && e_cur && (e_cur->security & SEC_ENCRYPT))
2271  e_templ->security |= SEC_SIGN;
2272  if (((WithCrypto & APPLICATION_PGP) != 0) &&
2274  {
2275  if (C_PgpAutoinline)
2276  e_templ->security |= SEC_INLINE;
2277  if (C_PgpReplyinline && e_cur && (e_cur->security & SEC_INLINE))
2278  e_templ->security |= SEC_INLINE;
2279  }
2280  }
2281 
2282  if (e_templ->security || C_CryptOpportunisticEncrypt)
2283  {
2284  /* When replying / forwarding, use the original message's
2285  * crypto system. According to the documentation,
2286  * smime_is_default should be disregarded here.
2287  *
2288  * Problem: At least with forwarding, this doesn't really
2289  * make much sense. Should we have an option to completely
2290  * disable individual mechanisms at run-time? */
2291  if (e_cur)
2292  {
2293  if (((WithCrypto & APPLICATION_PGP) != 0) && C_CryptAutopgp &&
2294  (e_cur->security & APPLICATION_PGP))
2295  {
2296  e_templ->security |= APPLICATION_PGP;
2297  }
2298  else if (((WithCrypto & APPLICATION_SMIME) != 0) && C_CryptAutosmime &&
2299  (e_cur->security & APPLICATION_SMIME))
2300  {
2301  e_templ->security |= APPLICATION_SMIME;
2302  }
2303  }
2304 
2305  /* No crypto mechanism selected? Use availability + smime_is_default
2306  * for the decision. */
2307  if (!(e_templ->security & (APPLICATION_SMIME | APPLICATION_PGP)))
2308  {
2310  {
2311  e_templ->security |= APPLICATION_SMIME;
2312  }
2313  else if (((WithCrypto & APPLICATION_PGP) != 0) && C_CryptAutopgp)
2314  {
2315  e_templ->security |= APPLICATION_PGP;
2316  }
2317  else if (((WithCrypto & APPLICATION_SMIME) != 0) && C_CryptAutosmime)
2318  {
2319  e_templ->security |= APPLICATION_SMIME;
2320  }
2321  }
2322  }
2323 
2324  /* opportunistic encrypt relies on SMIME or PGP already being selected */
2326  {
2327  /* If something has already enabled encryption, e.g. C_CryptAutoencrypt
2328  * or C_CryptReplyencrypt, then don't enable opportunistic encrypt for
2329  * the message. */
2330  if (!(e_templ->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)))
2331  {
2332  e_templ->security |= SEC_OPPENCRYPT;
2333  crypt_opportunistic_encrypt(e_templ);
2334  }
2335  }
2336 
2337  /* No permissible mechanisms found. Don't sign or encrypt. */
2338  if (!(e_templ->security & (APPLICATION_SMIME | APPLICATION_PGP)))
2339  e_templ->security = SEC_NO_FLAGS;
2340  }
2341 
2342  /* Deal with the corner case where the crypto module backend is not available.
2343  * This can happen if configured without pgp/smime and with gpgme, but
2344  * $crypt_use_gpgme is unset. */
2345  if (e_templ->security && !crypt_has_module_backend(e_templ->security))
2346  {
2347  mutt_error(_(
2348  "No crypto backend configured. Disabling message security setting."));
2349  e_templ->security = SEC_NO_FLAGS;
2350  }
2351 
2352  /* specify a default fcc. if we are in batchmode, only save a copy of
2353  * the message if the value of $copy is yes or ask-yes */
2354 
2355  if (!fcc[0] && !(flags & SEND_POSTPONED_FCC) && (!(flags & SEND_BATCH) || (C_Copy & 0x1)))
2356  {
2357  /* set the default FCC */
2358  const bool killfrom = TAILQ_EMPTY(&e_templ->env->from);
2359  if (killfrom)
2360  {
2362  }
2363  mutt_select_fcc(fcc, sizeof(fcc), e_templ);
2364  if (killfrom)
2365  {
2366  mutt_addrlist_clear(&e_templ->env->from);
2367  }
2368  }
2369 
2370  mutt_update_encoding(e_templ->content);
2371 
2372  if (!(flags & (SEND_MAILX | SEND_BATCH)))
2373  {
2374  main_loop:
2375 
2376  mutt_pretty_mailbox(fcc, sizeof(fcc));
2377  i = mutt_compose_menu(e_templ, fcc, sizeof(fcc), e_cur,
2379  if (i == -1)
2380  {
2381 /* abort */
2382 #ifdef USE_NNTP
2383  if (flags & SEND_NEWS)
2384  mutt_message(_("Article not posted"));
2385  else
2386 #endif
2387  mutt_message(_("Mail not sent"));
2388  goto cleanup;
2389  }
2390  else if (i == 1)
2391  {
2392  if (postpone_message(e_templ, e_cur, fcc, flags) != 0)
2393  goto main_loop;
2394  mutt_message(_("Message postponed"));
2395  rc = 1;
2396  goto cleanup;
2397  }
2398  }
2399 
2400 #ifdef USE_NNTP
2401  if (!(flags & SEND_NEWS))
2402 #endif
2403  if ((mutt_addrlist_count_recips(&e_templ->env->to) == 0) &&
2404  (mutt_addrlist_count_recips(&e_templ->env->cc) == 0) &&
2405  (mutt_addrlist_count_recips(&e_templ->env->bcc) == 0))
2406  {
2407  if (!(flags & SEND_BATCH))
2408  {
2409  mutt_error(_("No recipients specified"));
2410  goto main_loop;
2411  }
2412  else
2413  {
2414  puts(_("No recipients specified"));
2415  goto cleanup;
2416  }
2417  }
2418 
2419  if (mutt_env_to_intl(e_templ->env, &tag, &err))
2420  {
2421  mutt_error(_("Bad IDN in '%s': '%s'"), tag, err);
2422  FREE(&err);
2423  if (!(flags & SEND_BATCH))
2424  goto main_loop;
2425  else
2426  goto cleanup;
2427  }
2428 
2429  if (!e_templ->env->subject && !(flags & SEND_BATCH) &&
2430  (query_quadoption(C_AbortNosubject, _("No subject, abort sending?")) != MUTT_NO))
2431  {
2432  /* if the abort is automatic, print an error message */
2433  if (C_AbortNosubject == MUTT_YES)
2434  mutt_error(_("No subject specified"));
2435  goto main_loop;
2436  }
2437 #ifdef USE_NNTP
2438  if ((flags & SEND_NEWS) && !e_templ->env->subject)
2439  {
2440  mutt_error(_("No subject specified"));
2441  goto main_loop;
2442  }
2443 
2444  if ((flags & SEND_NEWS) && !e_templ->env->newsgroups)
2445  {
2446  mutt_error(_("No newsgroup specified"));
2447  goto main_loop;
2448  }
2449 #endif
2450 
2451  if (!(flags & SEND_BATCH) && (C_AbortNoattach != MUTT_NO) &&
2452  !e_templ->content->next && (e_templ->content->type == TYPE_TEXT) &&
2453  (mutt_str_strcasecmp(e_templ->content->subtype, "plain") == 0) &&
2454  search_attach_keyword(e_templ->content->filename) &&
2456  _("No attachments, cancel sending?")) != MUTT_NO))
2457  {
2458  /* if the abort is automatic, print an error message */
2459  if (C_AbortNoattach == MUTT_YES)
2460  {
2461  mutt_error(_("Message contains text matching "
2462  "\"$abort_noattach_regex\". Not sending."));
2463  }
2464  goto main_loop;
2465  }
2466 
2467  if (e_templ->content->next)
2468  e_templ->content = mutt_make_multipart(e_templ->content);
2469 
2470  /* Ok, we need to do it this way instead of handling all fcc stuff in
2471  * one place in order to avoid going to main_loop with encoded "env"
2472  * in case of error. Ugh. */
2473 
2474  mutt_encode_descriptions(e_templ->content, true);
2475 
2476  /* Make sure that clear_content and free_clear_content are
2477  * properly initialized -- we may visit this particular place in
2478  * the code multiple times, including after a failed call to
2479  * mutt_protect(). */
2480 
2481  clear_content = NULL;
2482  free_clear_content = false;
2483 
2484  if (WithCrypto)
2485  {
2486  if (e_templ->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT))
2487  {
2488  /* save the decrypted attachments */
2489  clear_content = e_templ->content;
2490 
2491  if ((crypt_get_keys(e_templ, &pgpkeylist, 0) == -1) ||
2492  (mutt_protect(e_templ, pgpkeylist, false) == -1))
2493  {
2494  e_templ->content = mutt_remove_multipart(e_templ->content);
2495 
2496  FREE(&pgpkeylist);
2497 
2498  decode_descriptions(e_templ->content);
2499  goto main_loop;
2500  }
2501  mutt_encode_descriptions(e_templ->content, false);
2502  }
2503 
2504  /* at this point, e_templ->content is one of the following three things:
2505  * - multipart/signed. In this case, clear_content is a child
2506  * - multipart/encrypted. In this case, clear_content exists independently
2507  * - application/pgp. In this case, clear_content exists independently
2508  * - something else. In this case, it's the same as clear_content
2509  */
2510 
2511  /* This is ugly -- lack of "reporting back" from mutt_protect(). */
2512 
2513  if (clear_content && (e_templ->content != clear_content) &&
2514  (e_templ->content->parts != clear_content))
2515  free_clear_content = true;
2516  }
2517 
2518  if (!OptNoCurses && !(flags & SEND_MAILX))
2519  mutt_message(_("Sending message..."));
2520 
2521  mutt_prepare_envelope(e_templ->env, true);
2522 
2523  if (C_FccBeforeSend)
2524  save_fcc(e_templ, fcc, sizeof(fcc), clear_content, pgpkeylist, flags, &finalpath);
2525 
2526  i = send_message(e_templ);
2527  if (i < 0)
2528  {
2529  if (!(flags & SEND_BATCH))
2530  {
2531  if (!WithCrypto)
2532  ;
2533  else if ((e_templ->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) ||
2534  ((e_templ->security & SEC_SIGN) && (e_templ->content->type == TYPE_APPLICATION)))
2535  {
2536  if (e_templ->content != clear_content)
2537  {
2538  mutt_body_free(&e_templ->content); /* destroy PGP data */
2539  e_templ->content = clear_content; /* restore clear text. */
2540  }
2541  }
2542  else if ((e_templ->security & SEC_SIGN) && (e_templ->content->type == TYPE_MULTIPART))
2543  {
2544  mutt_body_free(&e_templ->content->parts->next); /* destroy sig */
2545  e_templ->content = mutt_remove_multipart(e_templ->content);
2546  }
2547 
2548  FREE(&pgpkeylist);
2549  mutt_env_free(&e_templ->content->mime_headers); /* protected headers */
2550  e_templ->content = mutt_remove_multipart(e_templ->content);
2551  decode_descriptions(e_templ->content);
2552  mutt_unprepare_envelope(e_templ->env);
2553  FREE(&finalpath);
2554  goto main_loop;
2555  }
2556  else
2557  {
2558  puts(_("Could not send the message"));
2559  goto cleanup;
2560  }
2561  }
2562 
2563  if (!C_FccBeforeSend)
2564  save_fcc(e_templ, fcc, sizeof(fcc), clear_content, pgpkeylist, flags, &finalpath);
2565 
2566  if (!OptNoCurses && !(flags & SEND_MAILX))
2567  {
2568  mutt_message((i != 0) ? _("Sending in background") :
2569  (flags & SEND_NEWS) ? _("Article posted") : /* USE_NNTP */
2570  _("Mail sent"));
2571 #ifdef USE_NOTMUCH
2572  if (C_NmRecord)
2573  nm_record_message(ctx ? ctx->mailbox : NULL, finalpath, e_cur);
2574 #endif
2575  mutt_sleep(0);
2576  }
2577 
2578  if (WithCrypto)
2579  FREE(&pgpkeylist);
2580 
2581  if ((WithCrypto != 0) && free_clear_content)
2582  mutt_body_free(&clear_content);
2583 
2584  /* set 'replied' flag only if the user didn't change/remove
2585  * In-Reply-To: and References: headers during edit */
2586  if (flags & SEND_REPLY)
2587  {
2588  if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox)
2589  {
2590  STAILQ_FOREACH(en, el, entries)
2591  {
2592  mutt_set_flag(ctx->mailbox, en->email, MUTT_REPLIED, is_reply(en->email, e_templ));
2593  }
2594  }
2595  }
2596 
2597  rc = 0;
2598 
2599 cleanup:
2600 
2601  if (flags & SEND_POSTPONED)
2602  {
2603  if (WithCrypto & APPLICATION_PGP)
2604  {
2605  FREE(&C_PgpSignAs);
2606  C_PgpSignAs = pgp_signas;
2607  }
2609  {
2610  FREE(&C_SmimeSignAs);
2611  C_SmimeSignAs = smime_signas;
2612  }
2613  }
2614 
2615  mutt_file_fclose(&fp_tmp);
2616  if (!(flags & SEND_NO_FREE_HEADER))
2617  email_free(&e_templ);
2618 
2619  FREE(&finalpath);
2620  return rc;
2621 }
#define MUTT_SEND_HOOK
send-hook: when composing a new email
Definition: hook.h:47
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:410
void mutt_fix_reply_recipients(struct Envelope *env)
Remove duplicate recipients.
Definition: send.c:885
WHERE char * Username
User&#39;s login name.
Definition: globals.h:52
The "current" mailbox.
Definition: context.h:36
struct Regex * C_AbortNoattachRegex
Config: Regex to match text indicating attachments are expected.
Definition: send.c:93
WHERE char * C_SmtpUrl
Config: (smtp) Url of the SMTP server.
Definition: globals.h:147
static void make_reference_headers(struct EmailList *el, struct Envelope *env)
Generate reference headers for an email.
Definition: send.c:968
bool C_Hdrs
Config: Add custom headers to outgoing mail.
Definition: send.c:117
struct Body * mutt_make_message_attach(struct Mailbox *m, struct Email *e, bool attach_msg)
Create a message attachment.
Definition: sendlib.c:1486
Notmuch virtual mailbox type.
char * C_PostponeEncryptAs
Config: Fallback encryption key for postponed messages.
Definition: send.c:126
void mutt_actx_free(struct AttachCtx **ptr)
Free an Attachment Context.
Definition: attach.c:140
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define NONULL(x)
Definition: string2.h:37
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:205
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
Miscellaneous email parsing routines.
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: sendlib.c:1742
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:69
Representation of the email&#39;s header.
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:304
#define SEND_POSTPONED_FCC
Used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present.
Definition: send.h:96
#define SEND_TO_SENDER
Compose new email to sender.
Definition: send.h:99
The envelope/body of an email.
Definition: email.h:39
WHERE bool C_WriteBcc
Config: Write out the &#39;Bcc&#39; field when preparing to send a mail.
Definition: globals.h:273
#define TAILQ_FIRST(head)
Definition: queue.h:717
#define mutt_perror(...)
Definition: logging.h:85
char * C_ForwardAttributionIntro
Config: Prefix message for forwarded messages.
Definition: send.c:112
GUI editor for an email&#39;s headers.
WHERE char * C_AttributionLocale
Config: Locale for dates in the attribution message.
Definition: globals.h:103
static void fix_end_of_file(const char *data)
Ensure a file ends with a linefeed.
Definition: send.c:1444
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:65
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2425
struct AddressList mail_followup_to
Email&#39;s &#39;mail-followup-to&#39;.
Definition: envelope.h:63
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
WHERE bool C_AutocryptReply
Config: Replying to an autocrypt email automatically enables autocrypt in the reply.
Definition: globals.h:206
GUI miscellaneous curses (window drawing) routines.
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: mailbox.h:51
bool C_ReplySelf
Config: Really reply to yourself, when replying to your own email.
Definition: send.c:128
Structs that make up an email.
String processing routines to generate the mail index.
void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Email *e, struct Body *parts, FILE *fp, int parent_type, int level, bool decrypted)
Create a list of attachments.
Definition: recvattach.c:1224
The "currently-open" mailbox.
unsigned char C_AbortNoattach
Config: Abort sending the email if attachments are missing.
Definition: send.c:92
struct AddressList reply_to
Email&#39;s &#39;reply-to&#39;.
Definition: envelope.h:62
static bool search_attach_keyword(char *filename)
Search an email for &#39;attachment&#39; keywords.
Definition: send.c:1531
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:457
WHERE bool C_ForwardDecode
Config: Decode the message when forwarding it.
Definition: globals.h:219
User aborted the question (with Ctrl-G)
Definition: quad.h:37
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3331
#define mutt_message(...)
Definition: logging.h:83
int mutt_parse_mailto(struct Envelope *e, char **body, const char *src)
Parse a mailto:// url.
Definition: parse.c:1587
WHERE char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
Definition: globals.h:171
struct Email * email
Used by recvattach for updating.
Definition: attach.h:51
static void add_references(struct ListHead *head, struct Envelope *env)
Add the email&#39;s references to a list.
Definition: send.c:857
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1298
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1381
char * C_ForwardFormat
Config: printf-like format string to control the subject when forwarding a message.
Definition: send.c:115
#define SEND_DRAFT_FILE
Used by the -H flag.
Definition: send.h:98
static char * nntp_get_header(const char *s)
Get the trimmed header.
Definition: send.c:343
#define SEC_AUTOCRYPT_OVERRIDE
Indicates manual set/unset of encryption.
Definition: ncrypt.h:132
void mutt_expand_aliases_env(struct Envelope *env)
Expand aliases in all the fields of an Envelope.
Definition: alias.c:318
WHERE char * AutocryptDefaultKey
Autocrypt default key id (used for postponing messages)
Definition: globals.h:93
Pass files through external commands (filters)
static int envelope_defaults(struct Envelope *env, struct Mailbox *m, struct EmailList *el, SendFlags flags)
Fill in some defaults for a new email.
Definition: send.c:1005
static size_t plen
Length of cached packet.
Definition: pgppacket.c:38
A normal Email, write full header + MIME headers.
Definition: sendlib.h:60
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
static void process_user_header(struct Envelope *env)
Process the user headers.
Definition: send.c:381
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
Definition: crypt.c:1082
#define SEND_FORWARD
Forward email.
Definition: send.h:90
int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags)
Generate recpients for a reply email.
Definition: send.c:802
bool mutt_is_mail_list(const struct Address *addr)
Is this the email address of a mailing list?
Definition: hdrline.c:101
NeoMutt Logging.
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:727
bool C_FccBeforeSend
Config: Save FCCs before sending the message.
Definition: send.c:109
regex_t * regex
compiled expression
Definition: regex3.h:60
struct Body * content
List of MIME parts.
Definition: email.h:92
int mutt_edit_attachment(struct Body *a)
Edit an attachment.
Definition: mutt_attach.c:254
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:52
void mutt_forward_intro(struct Mailbox *m, struct Email *e, FILE *fp)
Add the "start of forwarded message" text.
Definition: send.c:432
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:729
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
static int save_fcc(struct Email *e, char *fcc, size_t fcc_len, struct Body *clear_content, char *pgpkeylist, SendFlags flags, char **finalpath)
Save an Email to a &#39;sent mail&#39; folder.
Definition: send.c:1573
struct ListHead userhdrs
user defined headers
Definition: envelope.h:83
bool C_PostponeEncrypt
Config: Self-encrypt postponed messages.
Definition: send.c:125
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Mailbox.
Definition: copy.c:806
#define _(a)
Definition: message.h:28
unsigned char C_AbortUnmodified
Config: Abort the sending if the message hasn&#39;t been edited.
Definition: send.c:95
struct Address * mutt_addr_new(void)
Create a new Address.
Definition: address.c:384
void mutt_make_misc_reply_headers(struct Envelope *env, struct Envelope *curenv)
Set subject for a reply.
Definition: send.c:929
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
static void add_message_id(struct ListHead *head, struct Envelope *env)
Add the email&#39;s message ID to a list.
Definition: send.c:873
WHERE bool C_PgpAutoinline
Config: Use old-style inline PGP messages (not recommended)
Definition: globals.h:288
struct Body * next
next attachment in the list
Definition: body.h:53
short idxlen
Number of attachmentes.
Definition: attach.h:55
An email address.
Definition: address.h:34
8-bit text
Definition: mime.h:50
unsigned char C_Include
Config: Include a copy of the email that&#39;s being replied to.
Definition: send.c:120
WHERE unsigned char C_Copy
Config: Save outgoing emails to $record.
Definition: globals.h:186
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:46
char * mailbox
Mailbox and host address.
Definition: address.h:37
#define SEC_INLINE
Email has an inline signature.
Definition: ncrypt.h:129
bool C_CryptAutosign
Config: Automatically PGP sign all outgoing mail.
Definition: send.c:101
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
static int inline_forward_attachments(struct Mailbox *m, struct Email *e, struct Body ***plast, int *forwardq)
Add attachments to an email, inline.
Definition: send.c:520
bool C_FollowupTo
Config: Add the &#39;Mail-Followup-To&#39; header is generated when sending mail.
Definition: send.c:111
size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display)
Write an Address to a buffer.
Definition: address.c:1137
bool C_SigDashes
Config: Insert &#39;– &#39; before the signature.
Definition: send.c:133
bool C_IgnoreListReplyTo
Config: Ignore the &#39;Reply-To&#39; header when using <reply> on a mailing list.
Definition: send.c:119
static int default_to(struct AddressList *to, struct Envelope *env, SendFlags flags, int hmfupto)
Generate default email addresses.
Definition: send.c:721
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:706
int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode)
Check we have all the keys we need.
Definition: crypt.c:952
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:606
uint16_t SendFlags
Flags for ci_send_message(), e.g. SEND_REPLY.
Definition: send.h:85
int mutt_env_to_intl(struct Envelope *env, const char **tag, char **err)
Convert an Envelope&#39;s Address fields to Punycode format.
Definition: envelope.c:312
void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *fp_out)
Add suffix to replied email text.
Definition: send.c:660
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:439
struct Address * mutt_addr_create(const char *personal, const char *mailbox)
Create and populate a new Address.
Definition: address.c:397
#define SEND_POSTPONED
Recall a postponed email.
Definition: send.h:91
bool C_CryptReplysign
Config: Sign replies to signed messages.
Definition: send.c:104
Representation of a single alias to an email address.
#define MUTT_CM_REPLYING
Replying the message.
Definition: copy.h:43
void mutt_select_fcc(char *path, size_t pathlen, struct Email *e)
Select the FCC path for an email.
Definition: hook.c:700
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
Messages that have been replied to.
Definition: mutt.h:101
int vcount
The number of virtual messages.
Definition: mailbox.h:113
The body of an email.
Definition: body.h:34
void mutt_prepare_envelope(struct Envelope *env, bool final)
Prepare an email header.
Definition: sendlib.c:2997
unsigned int disposition
content-disposition
Definition: body.h:67
Convenience wrapper for the config headers.
Prepare and send an email.
char * C_ForwardAttributionTrailer
Config: Suffix message for forwarded messages.
Definition: send.c:113
Hundreds of global variables to back the user variables.
int mutt_rfc822_write_header(FILE *fp, struct Envelope *env, struct Body *attach, enum MuttWriteHeaderMode mode, bool privacy, bool hide_protected_subject)
Write out one RFC822 header line.
Definition: sendlib.c:2324
Email Address Handling.
unsigned char C_HonorFollowupTo
Config: Honour the &#39;Mail-Followup-To&#39; header when group replying.
Definition: send.c:118
Assorted sorting methods.
int nm_record_message(struct Mailbox *m, char *path, struct Email *e)
Add a message to the Notmuch database.
Some miscellaneous functions.
WHERE bool C_SmimeIsDefault
Config: Use SMIME rather than PGP by default.
Definition: globals.h:284
#define mutt_array_size(x)
Definition: memory.h:33
bool C_CryptAutosmime
Config: Allow automatic SMIME functions.
Definition: send.c:102
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1087
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
bool tagged
Email is tagged.
Definition: email.h:46
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1318
bool read
Email is read.
Definition: email.h:53
WHERE bool C_UseDomain
Config: Qualify local addresses using this domain.
Definition: globals.h:270
#define SEND_MAILX
Send email in Mailx compatibility mode.
Definition: send.h:93
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1509
char * C_SendCharset
Config: Character sets for outgoing mail.
Definition: email_globals.c:38
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
char * message_id
Message ID.
Definition: envelope.h:69
WHERE bool C_EditHeaders
Config: Let the user edit the email headers whilst editing an email.
Definition: globals.h:217
struct Mailbox * mailbox
Definition: context.h:50
unsigned char C_Recall
Config: Recall postponed mesaages when asked to compose a message.
Definition: send.c:127
Parse and execute user-defined hooks.
int mutt_invoke_sendmail(struct AddressList *from, struct AddressList *to, struct AddressList *cc, struct AddressList *bcc, const char *msg, int eightbit)
Run sendmail.
Definition: sendlib.c:2819
struct Body * mutt_body_new(void)
Create a new Body.
Definition: body.c:43
API for mailboxes.
unsigned char C_ReplyTo
Config: Address to use as a &#39;Reply-To&#39; header.
Definition: send.c:129
bool old
Email is seen, but unread.
Definition: email.h:52
#define TAILQ_FOREACH_REVERSE(var, head, headname, field)
Definition: queue.h:739
void rfc2047_decode(char **pd)
Decode any RFC2047-encoded header fields.
Definition: rfc2047.c:649
unsigned char C_AbortNosubject
Config: Abort creating the email if subject is missing.
Definition: send.c:94
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
WHERE unsigned char C_MimeForward
Config: Forward a message as a &#39;message/RFC822&#39; MIME part.
Definition: globals.h:189
void mutt_update_encoding(struct Body *a)
Update the encoding type.
Definition: sendlib.c:1455
static void process_user_recips(struct Envelope *env)
Process the user headers.
Definition: send.c:354
#define CH_WEED
Weed the headers?
Definition: copy.h:52
void emaillist_clear(struct EmailList *el)
Drop a private list of Emails.
Definition: email.c:127
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:150
IMAP network mailbox.
WHERE struct Address * C_From
Config: Default &#39;From&#39; address to use, if isn&#39;t otherwise set.
Definition: globals.h:99
struct Envelope * env
Envelope information.
Definition: email.h:91
Convenience wrapper for the core headers.
int mutt_body_copy(FILE *fp, struct Body **tgt, struct Body *src)
Create a send-mode duplicate from a receive-mode body.
Definition: mutt_body.c:47
static void decode_descriptions(struct Body *b)
rfc2047 decode them in case of an error
Definition: send.c:1427
struct ListNode * mutt_list_find(const struct ListHead *h, const char *data)
Find a string in a List.
Definition: list.c:103
#define SKIPWS(ch)
Definition: string2.h:47
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
WHERE bool C_Autoedit
Config: Skip the initial compose menu and edit the email.
Definition: globals.h:208
int el_add_email(struct EmailList *el, struct Email *e)
Get a list of the selected Emails.
Definition: context.c:398
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:89
static bool is_reply(struct Email *reply, struct Email *orig)
Is one email a reply to another?
Definition: send.c:1513
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:109
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
void * mdata
Driver specific data.
Definition: mailbox.h:147
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:42
int mutt_write_multiple_fcc(const char *path, struct Email *e, const char *msgid, bool post, char *fcc, char **finalpath)
Handle FCC with multiple, comma separated entries.
Definition: sendlib.c:3199
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
Definition: sendlib.c:1716
#define SEND_KEY
Mail a PGP public key.
Definition: send.h:94
int mutt_autocrypt_set_sign_as_default_key(struct Email *e)
Set the Autocrypt default key for signing.
Definition: autocrypt.c:675
char * subtype
content-type subtype
Definition: body.h:37
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:821
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
bool C_FastReply
Config: Don&#39;t prompt for the recipients and subject when replying/forwarding.
Definition: send.c:107
WHERE bool C_Header
Config: Include the message headers in the reply email (Weed applies)
Definition: globals.h:226
#define MUTT_CM_PREFIX
Quote the header and body.
Definition: copy.h:36
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:843
Prototypes for many functions.
char * x_comment_to
List of &#39;X-comment-to&#39; fields.
Definition: envelope.h:78
#define SEND_RESEND
Reply using the current email as a template.
Definition: send.h:95
Representation of the body of an email.
void mutt_set_followup_to(struct Envelope *env)
Set followup-to field.
Definition: send.c:1187
void mutt_unprepare_envelope(struct Envelope *env)
Undo the encodings of mutt_prepare_envelope()
Definition: sendlib.c:3036
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
bool C_AskXCommentTo
Config: (nntp) Ask the user for the &#39;X-Comment-To&#39; field before editing.
Definition: send.c:97
struct Address * mutt_default_from(void)
Get a default &#39;from&#39; Address.
Definition: send.c:1307
unsigned char C_FccAttach
Config: Save send message with all their attachments.
Definition: send.c:108
WHERE bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient&#39;s key is available.
Definition: globals.h:280
A local copy of an email.
Definition: mx.h:81
static int include_forward(struct Mailbox *m, struct Email *e, FILE *fp_out)
Write out a forwarded message.
Definition: send.c:473
bool C_ReverseName
Config: Set the &#39;From&#39; from the address the email was sent to.
Definition: send.c:131
int mutt_compose_menu(struct Email *e, char *fcc, size_t fcclen, struct Email *e_cur, int flags)
Allow the user to edit the message envelope.
Definition: compose.c:1049
A mailbox.
Definition: mailbox.h:92
#define PATH_MAX
Definition: mutt.h:52
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
void mutt_encode_descriptions(struct Body *b, bool recurse)
rfc2047 encode the content-descriptions
Definition: send.c:1410
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
Type: &#39;text/*&#39;.
Definition: mime.h:38
static int generate_body(FILE *fp_tmp, struct Email *e, SendFlags flags, struct Mailbox *m, struct EmailList *el)
Create a new email body.
Definition: send.c:1075
int mutt_write_mime_body(struct Body *a, FILE *fp)
Write a MIME part.
Definition: sendlib.c:521
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
bool mutt_can_decode(struct Body *a)
Will decoding the attachment produce any output.
Definition: handler.c:1749
static int include_reply(struct Mailbox *m, struct Email *e, FILE *fp_out)
Generate the reply text for an email.
Definition: send.c:679
bool mutt_addr_cmp(const struct Address *a, const struct Address *b)
Compare two e-mail addresses.
Definition: address.c:854
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
int mutt_protect(struct Email *e, char *keylist, bool postpone)
Encrypt and/or sign a message.
Definition: crypt.c:172
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
WHERE struct Regex * C_QuoteRegex
Config: Regex to match quoted text in a reply.
Definition: globals.h:182
RFC3676 Format Flowed routines.
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
void mutt_addrlist_prepend(struct AddressList *al, struct Address *a)
Prepend an Address to an AddressList.
Definition: address.c:1412
bool C_ReverseRealname
Config: Set the &#39;From&#39; from the full &#39;To&#39; address the email was sent to.
Definition: send.c:132
Ignore case when comparing strings.
Definition: string2.h:68
char * mutt_str_skip_email_wsp(const char *s)
Skip over whitespace as defined by RFC5322.
Definition: string.c:776
#define SEND_NEWS
Reply to a news article.
Definition: send.h:101
int ci_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Context *ctx, struct EmailList *el)
Send an email.
Definition: send.c:1837
Handling of email attachments.
bool C_FccClear
Config: Save sent messages unencrypted and unsigned.
Definition: send.c:110
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:46
int mix_send_message(struct ListHead *chain, const char *tempfile)
Send an email via Mixmaster.
Definition: remailer.c:832
API for encryption/signing of emails.
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:612
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
static void set_reverse_name(struct AddressList *al, struct Envelope *env)
Try to set the &#39;from&#39; field from the recipients.
Definition: send.c:1258
void mutt_update_num_postponed(void)
Force the update of the number of postponed messages.
Definition: postpone.c:195
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
bool C_PgpReplyinline
Config: Reply using old-style inline PGP messages (not recommended)
Definition: send.c:123
#define SEND_REPLY
Reply to sender.
Definition: send.h:87
NNTP-specific Mailbox data -.
Definition: nntp.h:138
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
bool C_SigOnTop
Config: Insert the signature before the quoted text.
Definition: send.c:135
const char * mutt_fqdn(bool may_hide_host)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:2527
bool C_AskFollowUp
Config: (nntp) Ask the user for follow-up groups before editing.
Definition: send.c:96
#define SEND_NO_FREE_HEADER
Used by the -E flag.
Definition: send.h:97
void rfc3676_space_stuff(struct Email *e)
Perform required RFC3676 space stuffing.
Definition: rfc3676.c:398
void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp)
Add a "end of forwarded message" text.
Definition: send.c:451
unsigned char C_ForwardEdit
Config: Automatically start the editor when forwarding a message.
Definition: send.c:114
void rfc2047_encode(char **pd, const char *specials, int col, const char *charsets)
RFC-2047-encode a string.
Definition: rfc2047.c:625
unsigned int type
content-type primary type
Definition: body.h:65
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: ncrypt.h:130
char * list_post
This stores a mailto URL, or nothing.
Definition: envelope.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
bool C_CryptReplyencrypt
Config: Encrypt replies to encrypted messages.
Definition: send.c:103
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
int mutt_addrlist_count_recips(const struct AddressList *al)
Count the number of Addresses with valid recipients.
Definition: address.c:834
bool crypt_has_module_backend(SecurityFlags type)
Is there a crypto backend for a given type?
Definition: cryptglue.c:159
char * personal
Real name of address.
Definition: address.h:36
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:112
int mutt_num_postponed(struct Mailbox *m, bool force)
Return the number of postponed messages.
Definition: postpone.c:85
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: globals.h:268
void mutt_parse_content_type(const char *s, struct Body *ct)
Parse a content type.
Definition: parse.c:455
void mutt_env_to_local(struct Envelope *env)
Convert an Envelope&#39;s Address fields to local format.
Definition: envelope.c:274
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1030
WHERE bool C_ResumeDraftFiles
Config: Process draft files like postponed messages.
Definition: globals.h:254
struct Body * crypt_pgp_make_key_attachment(void)
Wrapper for CryptModuleSpecs::pgp_make_key_attachment()
Definition: cryptglue.c:295
Send email to an SMTP server.
#define SEND_GROUP_REPLY
Reply to all.
Definition: send.h:88
GUI basic built-in text editor.
char * data
String.
Definition: list.h:35
char * subject
Email&#39;s subject.
Definition: envelope.h:66
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
Duplicate the structure of an entire email.
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1216
Routines for managing attachments.
Log at debug level 1.
Definition: logging.h:56
bool group
Group mailbox?
Definition: address.h:38
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
#define MUTT_SEND2_HOOK
send2-hook: when changing fields in the compose menu
Definition: hook.h:56
bool C_Metoo
Config: Remove the user&#39;s address from the list of recipients.
Definition: send.c:121
bool use_disp
Content-Disposition uses filename= ?
Definition: body.h:68
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:268
WHERE bool C_XCommentTo
Config: (nntp) Add &#39;X-Comment-To&#39; header that contains article author.
Definition: globals.h:294
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
static void add_mailing_lists(struct AddressList *out, const struct AddressList *t, const struct AddressList *c)
Search Address lists for mailing lists.
Definition: send.c:183
struct Body * content
Attachment.
Definition: attach.h:36
Autocrypt end-to-end encryption.
struct Email * email
Email in the list.
Definition: email.h:122
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
Cached regular expression.
Definition: regex3.h:57
#define mutt_error(...)
Definition: logging.h:84
bool mutt_needs_mailcap(struct Body *m)
Does this type need a mailcap entry do display.
Definition: muttlib.c:405
int mutt_builtin_editor(const char *path, struct Email *e_new, struct Email *e_cur)
Show the user the built-in editor.
Definition: edit.c:402
bool mutt_addr_valid_msgid(const char *msgid)
Is this a valid Message ID?
Definition: address.c:754
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:69
bool replied
Email has been replied to.
Definition: email.h:56
static int edit_envelope(struct Envelope *en, SendFlags flags)
Edit Envelope fields.
Definition: send.c:244
#define mutt_make_string(BUF, BUFLEN, S, CTX, M, E)
Definition: hdrline.h:61
char * followup_to
List of &#39;followup-to&#39; fields.
Definition: envelope.h:77
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
Definition: regex.c:610
WHERE char * C_Editor
Config: External command to use as an email editor.
Definition: globals.h:114
void mutt_edit_headers(const char *editor, const char *body, struct Email *e, char *fcc, size_t fcclen)
Let the user edit the message header and body.
Definition: mutt_header.c:168
bool C_UseFrom
Config: Set the &#39;From&#39; header for outgoing mail.
Definition: send.c:136
FILE * fp
pointer to the message data
Definition: mx.h:83
time_t mutt_file_decrease_mtime(const char *fp, struct stat *st)
Decrease a file&#39;s modification time by 1 second.
Definition: file.c:959
#define MUTT_REPLY_HOOK
reply-hook: when replying to an email
Definition: hook.h:55
#define mutt_enter_fname(prompt, buf, buflen, mailbox)
Definition: curs_lib.h:85
WHERE bool C_ForwardQuote
Config: Automatically quote a forwarded message using C_IndentString.
Definition: globals.h:220
void mutt_make_forward_subject(struct Envelope *env, struct Mailbox *m, struct Email *e)
Create a subject for a forwarded email.
Definition: send.c:912
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: pattern.c:1768
void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b)
Remove cross-references.
Definition: address.c:1354
WHERE char * C_PgpDefaultKey
Config: Default key to use for PGP operations.
Definition: globals.h:167
#define FREE(x)
Definition: memory.h:40
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:683
bool mutt_addrlist_search(const struct Address *needle, const struct AddressList *haystack)
Search for an e-mail address in a list.
Definition: address.c:871
#define MUTT_COMPOSE_NOFREEHEADER
Definition: compose.h:36
#define STAILQ_EMPTY(head)
Definition: queue.h:346
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
static int postpone_message(struct Email *e_post, struct Email *e_cur, char *fcc, SendFlags flags)
Save an Email for another day.
Definition: send.c:1740
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
int mutt_smtp_send(const struct AddressList *from, const struct AddressList *to, const struct AddressList *cc, const struct AddressList *bcc, const char *msgfile, bool eightbit)
Send a message using SMTP.
Definition: smtp.c:735
List of Emails.
Definition: email.h:120
struct Email * email_new(void)
Create a new Email.
Definition: email.c:68
#define TAILQ_NEXT(elm, field)
Definition: queue.h:816
WHERE char * C_Realname
Config: Real name of the user.
Definition: globals.h:143
int mutt_is_quote_line(char *line, regmatch_t *pmatch)
Is a line of message text a quote?
Definition: pager.c:945
Handling of global boolean variables.
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Miscellaneous functions for sending an email.
bool C_ForwardReferences
Config: Set the &#39;In-Reply-To&#39; and &#39;References&#39; headers when forwarding a message. ...
Definition: send.c:116
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
#define TAILQ_EMPTY(head)
Definition: queue.h:715
int mutt_str_asprintf(char **strp, const char *fmt,...)
Definition: string.c:1195
#define SEND_GROUP_CHAT_REPLY
Reply to all recipients preserving To/Cc.
Definition: send.h:100
#define MUTT_CM_NOHEADER
Don&#39;t copy the message header.
Definition: copy.h:35
WHERE bool OptNewsSend
(pseudo) used to change behavior when posting
Definition: options.h:44
WHERE char * C_Postponed
Config: Folder to store postponed messages.
Definition: globals.h:139
WHERE char * C_Attribution
Config: Message to start a reply, "On DATE, PERSON wrote:".
Definition: globals.h:102
Log at debug level 5.
Definition: logging.h:60
WHERE char * C_PgpSignAs
Config: Use this alternative key for signing messages.
Definition: globals.h:168
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:583
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:228
static void remove_user(struct AddressList *al, bool leave_only)
Remove any address which matches the current user.
Definition: send.c:164
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
WHERE char * C_SmimeSignAs
Config: Use this alternative key for signing messages.
Definition: globals.h:172
static void append_signature(FILE *fp)
Append a signature to an email.
Definition: send.c:142
A List node for strings.
Definition: list.h:33
#define TAILQ_SWAP(head1, head2, type, field)
Definition: queue.h:839
Match patterns to emails.
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:41
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1370
Decide how to display email content.
char * C_ContentType
Config: Default "Content-Type" for newly composed messages.
Definition: send.c:98
Content is inline.
Definition: mime.h:62
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
char * C_EmptySubject
Config: Subject to use when replying to an email with none.
Definition: send.c:106
int mutt_resend_message(FILE *fp, struct Context *ctx, struct Email *e_cur)
Resend an email.
Definition: send.c:1467
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:52
struct AddressList x_original_to
Email&#39;s &#39;X-Orig-to&#39;.
Definition: envelope.h:64
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:160
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: pattern.c:1780
A set of attachments.
Definition: attach.h:49
WHERE bool C_Askbcc
Config: Ask the user for the blind-carbon-copy recipients.
Definition: globals.h:202
int mutt_inline_forward(struct Mailbox *m, struct Email *e_edit, struct Email *e_cur, FILE *out)
Forward attachments, inline.
Definition: send.c:597
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
void mutt_edit_file(const char *editor, const char *file)
Let the user edit a file.
Definition: curs_lib.c:308
Convenience wrapper for the library headers.
char * mutt_extract_message_id(const char *s, const char **saveptr)
Find a message-id.
Definition: parse.c:357
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
static int send_message(struct Email *e)
Send an email.
Definition: send.c:1335
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1039
Type: &#39;application/*&#39;.
Definition: mime.h:33
int mutt_prepare_template(FILE *fp, struct Mailbox *m, struct Email *e_new, struct Email *e, bool resend)
Prepare a message template.
Definition: postpone.c:596
QuadOption
Possible values for a quad-option.
Definition: quad.h:35
int mutt_edit_address(struct AddressList *al, const char *field, bool expand_aliases)
Edit an email address.
Definition: send.c:210
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
Definition: parameter.c:110
Support of Mixmaster anonymous remailer.
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:84
char * C_Signature
Config: File containing a signature to append to all mail.
Definition: send.c:134
WHERE bool C_Askcc
Config: Ask the user for the carbon-copy recipients.
Definition: globals.h:203
#define SEND_BATCH
Send email in batch mode (without user interaction)
Definition: send.h:92
int mutt_get_postponed(struct Context *ctx, struct Email *hdr, struct Email **cur, char *fcc, size_t fcclen)
Recall a postponed message.
Definition: postpone.c:290
Usenet network mailbox type; talk to an NNTP server.
The header of an Email.
Definition: envelope.h:54
void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *fp_out)
Add "on DATE, PERSON wrote" header.
Definition: send.c:641
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
bool C_CryptReplysignencrypted
Config: Sign replies to encrypted messages.
Definition: send.c:105
bool C_NmRecord
Config: (notmuch) If the &#39;record&#39; mailbox (sent mail) should be indexed.
Definition: send.c:122
int msgno
Number displayed to the user.
Definition: email.h:88
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
Append an Address to an AddressList.
Definition: address.c:1401
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv)
Generate references for a reply email.
Definition: send.c:951
bool C_CryptAutopgp
Config: Allow automatic PGP functions.
Definition: send.c:100
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:155
WHERE unsigned char C_ForwardAttachments
Config: Forward attachments when forwarding a message.
Definition: globals.h:188
char * C_PostIndentString
Config: Suffix message to add after reply text.
Definition: send.c:124
bool C_CryptAutoencrypt
Config: Automatically PGP encrypt all outgoing mail.
Definition: send.c:99
bool C_ReplyWithXorig
Config: Create &#39;From&#39; header from &#39;X-Original-To&#39; header.
Definition: send.c:130
int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, bool post, char *fcc, char **finalpath)
Write email to FCC mailbox.
Definition: sendlib.c:3246