NeoMutt  2019-11-11
Teaching an old dog new tricks
DOXYGEN
send.c File Reference

Prepare and send an email. More...

#include "config.h"
#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "send.h"
#include "alias.h"
#include "compose.h"
#include "context.h"
#include "copy.h"
#include "curs_lib.h"
#include "edit.h"
#include "filter.h"
#include "globals.h"
#include "handler.h"
#include "hdrline.h"
#include "hook.h"
#include "mutt_attach.h"
#include "mutt_body.h"
#include "mutt_header.h"
#include "mutt_logging.h"
#include "mutt_parse.h"
#include "muttlib.h"
#include "ncrypt/ncrypt.h"
#include "options.h"
#include "pattern.h"
#include "protos.h"
#include "recvattach.h"
#include "rfc3676.h"
#include "sendlib.h"
#include "smtp.h"
#include "sort.h"
#include "mx.h"
#include "nntp/nntp.h"
#include "notmuch/mutt_notmuch.h"
#include "imap/imap.h"
#include "autocrypt/autocrypt.h"
+ Include dependency graph for send.c:

Go to the source code of this file.

Functions

static void append_signature (FILE *fp)
 Append a signature to an email. More...
 
static void remove_user (struct AddressList *al, bool leave_only)
 Remove any address which matches the current user. More...
 
static void add_mailing_lists (struct AddressList *out, const struct AddressList *t, const struct AddressList *c)
 Search Address lists for mailing lists. More...
 
int mutt_edit_address (struct AddressList *al, const char *field, bool expand_aliases)
 Edit an email address. More...
 
static int edit_envelope (struct Envelope *en, SendFlags flags)
 Edit Envelope fields. More...
 
static char * nntp_get_header (const char *s)
 Get the trimmed header. More...
 
static void process_user_recips (struct Envelope *env)
 Process the user headers. More...
 
static void process_user_header (struct Envelope *env)
 Process the user headers. More...
 
void mutt_forward_intro (struct Mailbox *m, struct Email *e, FILE *fp)
 Add the "start of forwarded message" text. More...
 
void mutt_forward_trailer (struct Mailbox *m, struct Email *e, FILE *fp)
 Add a "end of forwarded message" text. More...
 
static int include_forward (struct Mailbox *m, struct Email *e, FILE *fp_out)
 Write out a forwarded message. More...
 
static int inline_forward_attachments (struct Mailbox *m, struct Email *e, struct Body ***plast, int *forwardq)
 Add attachments to an email, inline. More...
 
int mutt_inline_forward (struct Mailbox *m, struct Email *e_edit, struct Email *e_cur, FILE *out)
 Forward attachments, inline. More...
 
void mutt_make_attribution (struct Mailbox *m, struct Email *e, FILE *fp_out)
 Add "on DATE, PERSON wrote" header. More...
 
void mutt_make_post_indent (struct Mailbox *m, struct Email *e, FILE *fp_out)
 Add suffix to replied email text. More...
 
static int include_reply (struct Mailbox *m, struct Email *e, FILE *fp_out)
 Generate the reply text for an email. More...
 
static const struct AddressList * choose_default_to (const struct Address *from, const struct Envelope *env)
 Pick the best 'to:' value. More...
 
static int default_to (struct AddressList *to, struct Envelope *env, SendFlags flags, int hmfupto)
 Generate default email addresses. More...
 
int mutt_fetch_recips (struct Envelope *out, struct Envelope *in, SendFlags flags)
 Generate recpients for a reply email. More...
 
static void add_references (struct ListHead *head, struct Envelope *env)
 Add the email's references to a list. More...
 
static void add_message_id (struct ListHead *head, struct Envelope *env)
 Add the email's message ID to a list. More...
 
void mutt_fix_reply_recipients (struct Envelope *env)
 Remove duplicate recipients. More...
 
void mutt_make_forward_subject (struct Envelope *env, struct Mailbox *m, struct Email *e)
 Create a subject for a forwarded email. More...
 
void mutt_make_misc_reply_headers (struct Envelope *env, struct Envelope *curenv)
 Set subject for a reply. More...
 
void mutt_add_to_reference_headers (struct Envelope *env, struct Envelope *curenv)
 Generate references for a reply email. More...
 
static void make_reference_headers (struct EmailList *el, struct Envelope *env)
 Generate reference headers for an email. More...
 
static int envelope_defaults (struct Envelope *env, struct Mailbox *m, struct EmailList *el, SendFlags flags)
 Fill in some defaults for a new email. More...
 
static int generate_body (FILE *fp_tmp, struct Email *e, SendFlags flags, struct Mailbox *m, struct EmailList *el)
 Create a new email body. More...
 
void mutt_set_followup_to (struct Envelope *env)
 Set followup-to field. More...
 
static void set_reverse_name (struct AddressList *al, struct Envelope *env)
 Try to set the 'from' field from the recipients. More...
 
struct Addressmutt_default_from (void)
 Get a default 'from' Address. More...
 
static int send_message (struct Email *e)
 Send an email. More...
 
void mutt_encode_descriptions (struct Body *b, bool recurse)
 rfc2047 encode the content-descriptions More...
 
static void decode_descriptions (struct Body *b)
 rfc2047 decode them in case of an error More...
 
static void fix_end_of_file (const char *data)
 Ensure a file ends with a linefeed. More...
 
int mutt_resend_message (FILE *fp, struct Context *ctx, struct Email *e_cur)
 Resend an email. More...
 
static bool is_reply (struct Email *reply, struct Email *orig)
 Is one email a reply to another? More...
 
static bool search_attach_keyword (char *filename)
 Search an email for 'attachment' keywords. More...
 
static int save_fcc (struct Email *e, struct Buffer *fcc, struct Body *clear_content, char *pgpkeylist, SendFlags flags, char **finalpath)
 Save an Email to a 'sent mail' folder. More...
 
static int postpone_message (struct Email *e_post, struct Email *e_cur, const char *fcc, SendFlags flags)
 Save an Email for another day. More...
 
int ci_send_message (SendFlags flags, struct Email *e_templ, const char *tempfile, struct Context *ctx, struct EmailList *el)
 Send an email. More...
 

Variables

unsigned char C_AbortNoattach
 Config: Abort sending the email if attachments are missing. More...
 
struct RegexC_AbortNoattachRegex
 Config: Regex to match text indicating attachments are expected. More...
 
unsigned char C_AbortNosubject
 Config: Abort creating the email if subject is missing. More...
 
unsigned char C_AbortUnmodified
 Config: Abort the sending if the message hasn't been edited. More...
 
bool C_AskFollowUp
 Config: (nntp) Ask the user for follow-up groups before editing. More...
 
bool C_AskXCommentTo
 Config: (nntp) Ask the user for the 'X-Comment-To' field before editing. More...
 
char * C_ContentType
 Config: Default "Content-Type" for newly composed messages. More...
 
bool C_CryptAutoencrypt
 Config: Automatically PGP encrypt all outgoing mail. More...
 
bool C_CryptAutopgp
 Config: Allow automatic PGP functions. More...
 
bool C_CryptAutosign
 Config: Automatically PGP sign all outgoing mail. More...
 
bool C_CryptAutosmime
 Config: Allow automatic SMIME functions. More...
 
bool C_CryptReplyencrypt
 Config: Encrypt replies to encrypted messages. More...
 
bool C_CryptReplysign
 Config: Sign replies to signed messages. More...
 
bool C_CryptReplysignencrypted
 Config: Sign replies to encrypted messages. More...
 
char * C_EmptySubject
 Config: Subject to use when replying to an email with none. More...
 
bool C_FastReply
 Config: Don't prompt for the recipients and subject when replying/forwarding. More...
 
unsigned char C_FccAttach
 Config: Save send message with all their attachments. More...
 
bool C_FccBeforeSend
 Config: Save FCCs before sending the message. More...
 
bool C_FccClear
 Config: Save sent messages unencrypted and unsigned. More...
 
bool C_FollowupTo
 Config: Add the 'Mail-Followup-To' header is generated when sending mail. More...
 
char * C_ForwardAttributionIntro
 Config: Prefix message for forwarded messages. More...
 
char * C_ForwardAttributionTrailer
 Config: Suffix message for forwarded messages. More...
 
unsigned char C_ForwardEdit
 Config: Automatically start the editor when forwarding a message. More...
 
char * C_ForwardFormat
 Config: printf-like format string to control the subject when forwarding a message. More...
 
bool C_ForwardReferences
 Config: Set the 'In-Reply-To' and 'References' headers when forwarding a message. More...
 
bool C_Hdrs
 Config: Add custom headers to outgoing mail. More...
 
unsigned char C_HonorFollowupTo
 Config: Honour the 'Mail-Followup-To' header when group replying. More...
 
bool C_IgnoreListReplyTo
 Config: Ignore the 'Reply-To' header when using <reply> on a mailing list. More...
 
unsigned char C_Include
 Config: Include a copy of the email that's being replied to. More...
 
bool C_Metoo
 Config: Remove the user's address from the list of recipients. More...
 
bool C_NmRecord
 Config: (notmuch) If the 'record' mailbox (sent mail) should be indexed. More...
 
bool C_PgpReplyinline
 Config: Reply using old-style inline PGP messages (not recommended) More...
 
char * C_PostIndentString
 Config: Suffix message to add after reply text. More...
 
bool C_PostponeEncrypt
 Config: Self-encrypt postponed messages. More...
 
char * C_PostponeEncryptAs
 Config: Fallback encryption key for postponed messages. More...
 
unsigned char C_Recall
 Config: Recall postponed mesaages when asked to compose a message. More...
 
bool C_ReplySelf
 Config: Really reply to yourself, when replying to your own email. More...
 
unsigned char C_ReplyTo
 Config: Address to use as a 'Reply-To' header. More...
 
bool C_ReplyWithXorig
 Config: Create 'From' header from 'X-Original-To' header. More...
 
bool C_ReverseName
 Config: Set the 'From' from the address the email was sent to. More...
 
bool C_ReverseRealname
 Config: Set the 'From' from the full 'To' address the email was sent to. More...
 
bool C_SigDashes
 Config: Insert '– ' before the signature. More...
 
char * C_Signature
 Config: File containing a signature to append to all mail. More...
 
bool C_SigOnTop
 Config: Insert the signature before the quoted text. More...
 
bool C_UseFrom
 Config: Set the 'From' header for outgoing mail. More...
 

Detailed Description

Prepare and send an email.

Authors
  • Michael R. Elkins
  • Pietro Cerutti

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file send.c.

Function Documentation

◆ append_signature()

static void append_signature ( FILE *  fp)
static

Append a signature to an email.

Parameters
fpFile to write to

Definition at line 141 of file send.c.

142 {
143  FILE *fp_tmp = NULL;
144  pid_t pid;
145 
146  if (C_Signature && (fp_tmp = mutt_open_read(C_Signature, &pid)))
147  {
148  if (C_SigDashes)
149  fputs("\n-- \n", fp);
150  mutt_file_copy_stream(fp_tmp, fp);
151  mutt_file_fclose(&fp_tmp);
152  if (pid != -1)
153  mutt_wait_filter(pid);
154  }
155 }
bool C_SigDashes
Config: Insert &#39;– &#39; before the signature.
Definition: send.c:132
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:270
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:221
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1404
char * C_Signature
Config: File containing a signature to append to all mail.
Definition: send.c:133
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove_user()

static void remove_user ( struct AddressList *  al,
bool  leave_only 
)
static

Remove any address which matches the current user.

Parameters
alList of addresses
leave_onlyIf set, don't remove the user's address if it it the only one in the list

Definition at line 163 of file send.c.

164 {
165  struct Address *a = NULL, *tmp = NULL;
166  TAILQ_FOREACH_SAFE(a, al, entries, tmp)
167  {
168  if (mutt_addr_is_user(a) && (!leave_only || TAILQ_NEXT(a, entries)))
169  {
170  TAILQ_REMOVE(al, a, entries);
171  mutt_addr_free(&a);
172  }
173  }
174 }
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:729
An email address.
Definition: address.h:34
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:439
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:821
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:682
#define TAILQ_NEXT(elm, field)
Definition: queue.h:816
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_mailing_lists()

static void add_mailing_lists ( struct AddressList *  out,
const struct AddressList *  t,
const struct AddressList *  c 
)
static

Search Address lists for mailing lists.

Parameters
outAddress list where to append matching mailing lists
t'To' Address list
c'Cc' Address list

Definition at line 182 of file send.c.

184 {
185  const struct AddressList *const als[] = { t, c };
186 
187  for (size_t i = 0; i < mutt_array_size(als); ++i)
188  {
189  const struct AddressList *al = als[i];
190  struct Address *a = NULL;
191  TAILQ_FOREACH(a, al, entries)
192  {
193  if (!a->group && mutt_is_mail_list(a))
194  {
196  }
197  }
198  }
199 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
bool mutt_is_mail_list(const struct Address *addr)
Is this the email address of a mailing list?
Definition: hdrline.c:116
An email address.
Definition: address.h:34
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:706
#define mutt_array_size(x)
Definition: memory.h:33
bool group
Group mailbox?
Definition: address.h:38
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
Append an Address to an AddressList.
Definition: address.c:1401
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_edit_address()

int mutt_edit_address ( struct AddressList *  al,
const char *  field,
bool  expand_aliases 
)

Edit an email address.

Parameters
[in,out]alAddressList to edit
[in]fieldPrompt for user
[in]expand_aliasesIf true, expand Address aliases
Return values
0Success
-1Failure

Definition at line 209 of file send.c.

210 {
211  char buf[8192];
212  char *err = NULL;
213  int idna_ok = 0;
214 
215  do
216  {
217  buf[0] = '\0';
219  mutt_addrlist_write(buf, sizeof(buf), al, false);
220  if (mutt_get_field(field, buf, sizeof(buf), MUTT_ALIAS) != 0)
221  return -1;
223  mutt_addrlist_parse2(al, buf);
224  if (expand_aliases)
226  idna_ok = mutt_addrlist_to_intl(al, &err);
227  if (idna_ok != 0)
228  {
229  mutt_error(_("Bad IDN: '%s'"), err);
230  FREE(&err);
231  }
232  } while (idna_ok != 0);
233  return 0;
234 }
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:303
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:63
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
Definition: address.c:1298
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1381
#define _(a)
Definition: message.h:28
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
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:606
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:91
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1216
#define mutt_error(...)
Definition: logging.h:84
#define FREE(x)
Definition: memory.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit_envelope()

static int edit_envelope ( struct Envelope en,
SendFlags  flags 
)
static

Edit Envelope fields.

Parameters
enEnvelope to edit
flagsFlags, see SendFlags
Return values
0Success
-1Failure

Definition at line 243 of file send.c.

244 {
245  char buf[8192];
246 
247 #ifdef USE_NNTP
248  if (OptNewsSend)
249  {
250  if (en->newsgroups)
251  mutt_str_strfcpy(buf, en->newsgroups, sizeof(buf));
252  else
253  buf[0] = '\0';
254  if (mutt_get_field("Newsgroups: ", buf, sizeof(buf), 0) != 0)
255  return -1;
256  FREE(&en->newsgroups);
257  en->newsgroups = mutt_str_strdup(buf);
258 
259  if (en->followup_to)
260  mutt_str_strfcpy(buf, en->followup_to, sizeof(buf));
261  else
262  buf[0] = '\0';
263  if (C_AskFollowUp && (mutt_get_field("Followup-To: ", buf, sizeof(buf), 0) != 0))
264  {
265  return -1;
266  }
267  FREE(&en->followup_to);
268  en->followup_to = mutt_str_strdup(buf);
269 
270  if (en->x_comment_to)
271  mutt_str_strfcpy(buf, en->x_comment_to, sizeof(buf));
272  else
273  buf[0] = '\0';
274  if (C_XCommentTo && C_AskXCommentTo &&
275  (mutt_get_field("X-Comment-To: ", buf, sizeof(buf), 0) != 0))
276  {
277  return -1;
278  }
279  FREE(&en->x_comment_to);
280  en->x_comment_to = mutt_str_strdup(buf);
281  }
282  else
283 #endif
284  {
285  if ((mutt_edit_address(&en->to, _("To: "), true) == -1) || TAILQ_EMPTY(&en->to))
286  return -1;
287  if (C_Askcc && (mutt_edit_address(&en->cc, _("Cc: "), true) == -1))
288  return -1;
289  if (C_Askbcc && (mutt_edit_address(&en->bcc, _("Bcc: "), true) == -1))
290  return -1;
292  (mutt_edit_address(&en->from, "From: ", true) == -1))
293  {
294  return -1;
295  }
296  }
297 
298  if (en->subject)
299  {
300  if (C_FastReply)
301  return 0;
302  mutt_str_strfcpy(buf, en->subject, sizeof(buf));
303  }
304  else
305  {
306  const char *p = NULL;
307 
308  buf[0] = '\0';
309  struct ListNode *uh = NULL;
310  STAILQ_FOREACH(uh, &UserHeader, entries)
311  {
312  size_t plen = mutt_str_startswith(uh->data, "subject:", CASE_IGNORE);
313  if (plen)
314  {
315  p = mutt_str_skip_email_wsp(uh->data + plen);
316  mutt_str_strfcpy(buf, p, sizeof(buf));
317  }
318  }
319  }
320 
321  if ((mutt_get_field(_("Subject: "), buf, sizeof(buf), 0) != 0) ||
322  (!buf[0] &&
323  (query_quadoption(C_AbortNosubject, _("No subject, abort?")) != MUTT_NO)))
324  {
325  mutt_message(_("No subject, aborting"));
326  return -1;
327  }
328  mutt_str_replace(&en->subject, buf);
329 
330  return 0;
331 }
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3340
#define mutt_message(...)
Definition: logging.h:83
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
static size_t plen
Length of cached packet.
Definition: pgppacket.c:38
#define _(a)
Definition: message.h:28
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:91
unsigned char C_AbortNosubject
Config: Abort creating the email if subject is missing.
Definition: send.c:93
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:90
bool C_FastReply
Config: Don&#39;t prompt for the recipients and subject when replying/forwarding.
Definition: send.c:106
char * x_comment_to
List of &#39;X-comment-to&#39; fields.
Definition: envelope.h:78
bool C_AskXCommentTo
Config: (nntp) Ask the user for the &#39;X-Comment-To&#39; field before editing.
Definition: send.c:96
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
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
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 STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define SEND_REPLY
Reply to sender.
Definition: send.h:88
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
bool C_AskFollowUp
Config: (nntp) Ask the user for follow-up groups before editing.
Definition: send.c:95
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
#define SEND_GROUP_REPLY
Reply to all.
Definition: send.h:89
char * data
String.
Definition: list.h:35
char * subject
Email&#39;s subject.
Definition: envelope.h:66
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
WHERE bool C_XCommentTo
Config: (nntp) Add &#39;X-Comment-To&#39; header that contains article author.
Definition: globals.h:292
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
char * followup_to
List of &#39;followup-to&#39; fields.
Definition: envelope.h:77
#define FREE(x)
Definition: memory.h:40
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_EMPTY(head)
Definition: queue.h:715
WHERE bool OptNewsSend
(pseudo) used to change behavior when posting
Definition: options.h:44
A List node for strings.
Definition: list.h:33
WHERE bool C_Askbcc
Config: Ask the user for the blind-carbon-copy recipients.
Definition: globals.h:200
int mutt_edit_address(struct AddressList *al, const char *field, bool expand_aliases)
Edit an email address.
Definition: send.c:209
WHERE bool C_Askcc
Config: Ask the user for the carbon-copy recipients.
Definition: globals.h:201
bool C_ReplyWithXorig
Config: Create &#39;From&#39; header from &#39;X-Original-To&#39; header.
Definition: send.c:129
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nntp_get_header()

static char* nntp_get_header ( const char *  s)
static

Get the trimmed header.

Parameters
sHeader line with leading whitespace
Return values
ptrCopy of string
Note
The caller should free the returned string.

Definition at line 341 of file send.c.

342 {
343  SKIPWS(s);
344  return mutt_str_strdup(s);
345 }
#define SKIPWS(ch)
Definition: string2.h:47
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_user_recips()

static void process_user_recips ( struct Envelope env)
static

Process the user headers.

Parameters
envEnvelope to populate

Definition at line 352 of file send.c.

353 {
354  struct ListNode *uh = NULL;
355  STAILQ_FOREACH(uh, &UserHeader, entries)
356  {
357  size_t plen;
358  if ((plen = mutt_str_startswith(uh->data, "to:", CASE_IGNORE)))
359  mutt_addrlist_parse(&env->to, uh->data + plen);
360  else if ((plen = mutt_str_startswith(uh->data, "cc:", CASE_IGNORE)))
361  mutt_addrlist_parse(&env->cc, uh->data + plen);
362  else if ((plen = mutt_str_startswith(uh->data, "bcc:", CASE_IGNORE)))
363  mutt_addrlist_parse(&env->bcc, uh->data + plen);
364 #ifdef USE_NNTP
365  else if ((plen = mutt_str_startswith(uh->data, "newsgroups:", CASE_IGNORE)))
366  env->newsgroups = nntp_get_header(uh->data + plen);
367  else if ((plen = mutt_str_startswith(uh->data, "followup-to:", CASE_IGNORE)))
368  env->followup_to = nntp_get_header(uh->data + plen);
369  else if ((plen = mutt_str_startswith(uh->data, "x-comment-to:", CASE_IGNORE)))
370  env->x_comment_to = nntp_get_header(uh->data + plen);
371 #endif
372  }
373 }
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:457
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
static char * nntp_get_header(const char *s)
Get the trimmed header.
Definition: send.c:341
static size_t plen
Length of cached packet.
Definition: pgppacket.c:38
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
char * x_comment_to
List of &#39;X-comment-to&#39; fields.
Definition: envelope.h:78
Ignore case when comparing strings.
Definition: string2.h:68
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
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
char * data
String.
Definition: list.h:35
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
char * followup_to
List of &#39;followup-to&#39; fields.
Definition: envelope.h:77
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
A List node for strings.
Definition: list.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_user_header()

static void process_user_header ( struct Envelope env)
static

Process the user headers.

Parameters
envEnvelope to populate

Definition at line 379 of file send.c.

380 {
381  struct ListNode *uh = NULL;
382  STAILQ_FOREACH(uh, &UserHeader, entries)
383  {
384  size_t plen;
385  if ((plen = mutt_str_startswith(uh->data, "from:", CASE_IGNORE)))
386  {
387  /* User has specified a default From: address. Remove default address */
388  mutt_addrlist_clear(&env->from);
389  mutt_addrlist_parse(&env->from, uh->data + plen);
390  }
391  else if ((plen = mutt_str_startswith(uh->data, "reply-to:", CASE_IGNORE)))
392  {
394  mutt_addrlist_parse(&env->reply_to, uh->data + plen);
395  }
396  else if ((plen = mutt_str_startswith(uh->data, "message-id:", CASE_IGNORE)))
397  {
398  char *tmp = mutt_extract_message_id(uh->data + plen, NULL);
399  if (mutt_addr_valid_msgid(tmp))
400  {
401  FREE(&env->message_id);
402  env->message_id = tmp;
403  }
404  else
405  FREE(&tmp);
406  }
407  else if (!mutt_str_startswith(uh->data, "to:", CASE_IGNORE) &&
408  !mutt_str_startswith(uh->data, "cc:", CASE_IGNORE) &&
409  !mutt_str_startswith(uh->data, "bcc:", CASE_IGNORE) &&
410 #ifdef USE_NNTP
411  !mutt_str_startswith(uh->data, "newsgroups:", CASE_IGNORE) &&
412  !mutt_str_startswith(uh->data, "followup-to:", CASE_IGNORE) &&
413  !mutt_str_startswith(uh->data, "x-comment-to:", CASE_IGNORE) &&
414 #endif
415  !mutt_str_startswith(uh->data, "supersedes:", CASE_IGNORE) &&
416  !mutt_str_startswith(uh->data, "subject:", CASE_IGNORE) &&
417  !mutt_str_startswith(uh->data, "return-path:", CASE_IGNORE))
418  {
420  }
421  }
422 }
struct AddressList reply_to
Email&#39;s &#39;reply-to&#39;.
Definition: envelope.h:62
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:457
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1381
static size_t plen
Length of cached packet.
Definition: pgppacket.c:38
struct ListHead userhdrs
user defined headers
Definition: envelope.h:83
char * message_id
Message ID.
Definition: envelope.h:69
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
Ignore case when comparing strings.
Definition: string2.h:68
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
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
char * data
String.
Definition: list.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
bool mutt_addr_valid_msgid(const char *msgid)
Is this a valid Message ID?
Definition: address.c:754
#define FREE(x)
Definition: memory.h:40
A List node for strings.
Definition: list.h:33
char * mutt_extract_message_id(const char *s, const char **saveptr)
Find a message-id.
Definition: parse.c:357
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_forward_intro()

void mutt_forward_intro ( struct Mailbox m,
struct Email e,
FILE *  fp 
)

Add the "start of forwarded message" text.

Parameters
mMailbox
eEmail
fpFile to write to

Definition at line 430 of file send.c.

431 {
432  if (!C_ForwardAttributionIntro || !fp)
433  return;
434 
435  char buf[1024];
436  setlocale(LC_TIME, NONULL(C_AttributionLocale));
437  mutt_make_string(buf, sizeof(buf), 0, C_ForwardAttributionIntro, NULL, m, e);
438  setlocale(LC_TIME, "");
439  fputs(buf, fp);
440  fputs("\n\n", fp);
441 }
#define NONULL(x)
Definition: string2.h:37
char * C_ForwardAttributionIntro
Config: Prefix message for forwarded messages.
Definition: send.c:111
WHERE char * C_AttributionLocale
Config: Locale for dates in the attribution message.
Definition: globals.h:100
#define mutt_make_string(BUF, BUFLEN, COLS, S, CTX, M, E)
Definition: hdrline.h:61
+ Here is the caller graph for this function:

◆ mutt_forward_trailer()

void mutt_forward_trailer ( struct Mailbox m,
struct Email e,
FILE *  fp 
)

Add a "end of forwarded message" text.

Parameters
mMailbox
eEmail
fpFile to write to

Definition at line 449 of file send.c.

450 {
451  if (!C_ForwardAttributionTrailer || !fp)
452  return;
453 
454  char buf[1024];
455  setlocale(LC_TIME, NONULL(C_AttributionLocale));
456  mutt_make_string(buf, sizeof(buf), 0, C_ForwardAttributionTrailer, NULL, m, e);
457  setlocale(LC_TIME, "");
458  fputc('\n', fp);
459  fputs(buf, fp);
460  fputc('\n', fp);
461 }
#define NONULL(x)
Definition: string2.h:37
WHERE char * C_AttributionLocale
Config: Locale for dates in the attribution message.
Definition: globals.h:100
#define mutt_make_string(BUF, BUFLEN, COLS, S, CTX, M, E)
Definition: hdrline.h:61
char * C_ForwardAttributionTrailer
Config: Suffix message for forwarded messages.
Definition: send.c:112
+ Here is the caller graph for this function:

◆ include_forward()

static int include_forward ( struct Mailbox m,
struct Email e,
FILE *  fp_out 
)
static

Write out a forwarded message.

Parameters
mMailbox
eEmail
fp_outFile to write to
Return values
0Success
-1Failure

Definition at line 471 of file send.c.

472 {
473  CopyHeaderFlags chflags = CH_DECODE;
475 
478 
479  if ((WithCrypto != 0) && (e->security & SEC_ENCRYPT) && C_ForwardDecode)
480  {
481  /* make sure we have the user's passphrase before proceeding... */
483  return -1;
484  }
485 
486  mutt_forward_intro(m, e, fp_out);
487 
488  if (C_ForwardDecode)
489  {
490  cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
491  if (C_Weed)
492  {
493  chflags |= CH_WEED | CH_REORDER;
494  cmflags |= MUTT_CM_WEED;
495  }
496  }
497  if (C_ForwardQuote)
498  cmflags |= MUTT_CM_PREFIX;
499 
500  mutt_copy_message(fp_out, m, e, cmflags, chflags, 0);
501  mutt_forward_trailer(m, e, fp_out);
502  return 0;
503 }
WHERE bool C_ForwardDecode
Config: Decode the message when forwarding it.
Definition: globals.h:217
void mutt_forward_intro(struct Mailbox *m, struct Email *e, FILE *fp)
Add the "start of forwarded message" text.
Definition: send.c:430
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Definition: copy.c:810
#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
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
#define CH_WEED
Weed the headers?
Definition: copy.h:52
#define MUTT_CM_PREFIX
Quote the header and body.
Definition: copy.h:36
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
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:39
void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp)
Add a "end of forwarded message" text.
Definition: send.c:449
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
WHERE bool C_ForwardQuote
Config: Automatically quote a forwarded message using C_IndentString.
Definition: globals.h:218
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:573
#define WithCrypto
Definition: ncrypt.h:160
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inline_forward_attachments()

static int inline_forward_attachments ( struct Mailbox m,
struct Email e,
struct Body ***  plast,
int *  forwardq 
)
static

Add attachments to an email, inline.

Parameters
[in]mMailbox
[in]eCurrent Email
[out]plastPointer to the last Attachment
[out]forwardqResult of asking the user to forward the attachments, e.g. MUTT_YES
Return values
0Success
-1Error

Definition at line 514 of file send.c.

516 {
517  struct Body **last = *plast;
518  struct Body *body = NULL;
519  struct Message *msg = NULL;
520  struct AttachCtx *actx = NULL;
521  int rc = 0, i;
522 
525 
526  msg = mx_msg_open(m, e->msgno);
527  if (!msg)
528  return -1;
529 
530  actx = mutt_mem_calloc(1, sizeof(*actx));
531  actx->email = e;
532  actx->fp_root = msg->fp;
533 
534  mutt_generate_recvattach_list(actx, actx->email, actx->email->content,
535  actx->fp_root, -1, 0, 0);
536 
537  for (i = 0; i < actx->idxlen; i++)
538  {
539  body = actx->idx[i]->content;
540  if ((body->type != TYPE_MULTIPART) && !mutt_can_decode(body) &&
541  !((body->type == TYPE_APPLICATION) &&
542  ((mutt_str_strcasecmp(body->subtype, "pgp-signature") == 0) ||
543  (mutt_str_strcasecmp(body->subtype, "x-pkcs7-signature") == 0) ||
544  (mutt_str_strcasecmp(body->subtype, "pkcs7-signature") == 0))))
545  {
546  /* Ask the quadoption only once */
547  if (*forwardq == -1)
548  {
550  /* L10N:
551  This is the prompt for $forward_attachments.
552  When inline forwarding ($mime_forward answered "no"), this prompts
553  whether to add non-decodable attachments from the original email.
554  Text/plain parts and the like will already be included in the
555  message contents, but other attachment, such as PDF files, will also
556  be added as attachments to the new mail, if this is answered yes.
557  */
558  _("Forward attachments?"));
559  if (*forwardq != MUTT_YES)
560  {
561  if (*forwardq == -1)
562  rc = -1;
563  goto cleanup;
564  }
565  }
566  if (mutt_body_copy(actx->idx[i]->fp, last, body) == -1)
567  {
568  rc = -1;
569  goto cleanup;
570  }
571  last = &((*last)->next);
572  }
573  }
574 
575 cleanup:
576  *plast = last;
577  mx_msg_close(m, &msg);
578  mutt_actx_free(&actx);
579  return rc;
580 }
void mutt_actx_free(struct AttachCtx **ptr)
Free an Attachment Context.
Definition: attach.c:140
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
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:1220
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3340
struct Email * email
Used by recvattach for updating.
Definition: attach.h:51
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
struct Body * content
List of MIME parts.
Definition: email.h:90
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:52
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
#define _(a)
Definition: message.h:28
short idxlen
Number of attachmentes.
Definition: attach.h:55
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
The body of an email.
Definition: body.h:34
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1101
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
char * subtype
content-type subtype
Definition: body.h:37
A local copy of an email.
Definition: mx.h:81
bool mutt_can_decode(struct Body *a)
Will decoding the attachment produce any output.
Definition: handler.c:1756
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
unsigned int type
content-type primary type
Definition: body.h:65
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
struct Body * content
Attachment.
Definition: attach.h:36
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
FILE * fp
pointer to the message data
Definition: mx.h:83
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:573
A set of attachments.
Definition: attach.h:49
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1053
Type: &#39;application/*&#39;.
Definition: mime.h:33
int msgno
Number displayed to the user.
Definition: email.h:86
WHERE unsigned char C_ForwardAttachments
Config: Forward attachments when forwarding a message.
Definition: globals.h:186
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_inline_forward()

int mutt_inline_forward ( struct Mailbox m,
struct Email e_edit,
struct Email e_cur,
FILE *  out 
)

Forward attachments, inline.

Parameters
mMailbox
e_editEmail to alter
e_curCurrent Email
outFile
Return values
0Success
-1Error

Definition at line 591 of file send.c.

593 {
594  int i, forwardq = -1;
595  struct Body **last = NULL;
596 
597  if (e_cur)
598  include_forward(m, e_cur, out);
599  else
600  for (i = 0; i < m->vcount; i++)
601  if (m->emails[m->v2r[i]]->tagged)
602  include_forward(m, m->emails[m->v2r[i]], out);
603 
605  {
606  last = &e_edit->content;
607  while (*last)
608  last = &((*last)->next);
609 
610  if (e_cur)
611  {
612  if (inline_forward_attachments(m, e_cur, &last, &forwardq) != 0)
613  return -1;
614  }
615  else
616  for (i = 0; i < m->vcount; i++)
617  if (m->emails[m->v2r[i]]->tagged)
618  {
619  if (inline_forward_attachments(m, m->emails[m->v2r[i]], &last, &forwardq) != 0)
620  return -1;
621  if (forwardq == MUTT_NO)
622  break;
623  }
624  }
625 
626  return 0;
627 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:110
WHERE bool C_ForwardDecode
Config: Decode the message when forwarding it.
Definition: globals.h:217
struct Body * content
List of MIME parts.
Definition: email.h:90
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:514
int vcount
The number of virtual messages.
Definition: mailbox.h:113
The body of an email.
Definition: body.h:34
bool tagged
Email is tagged.
Definition: email.h:44
static int include_forward(struct Mailbox *m, struct Email *e, FILE *fp_out)
Write out a forwarded message.
Definition: send.c:471
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:112
WHERE unsigned char C_ForwardAttachments
Config: Forward attachments when forwarding a message.
Definition: globals.h:186
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_make_attribution()

void mutt_make_attribution ( struct Mailbox m,
struct Email e,
FILE *  fp_out 
)

Add "on DATE, PERSON wrote" header.

Parameters
mMailbox
eEmail
fp_outFile to write to

Definition at line 635 of file send.c.

636 {
637  if (!C_Attribution || !fp_out)
638  return;
639 
640  char buf[1024];
641  setlocale(LC_TIME, NONULL(C_AttributionLocale));
642  mutt_make_string(buf, sizeof(buf), 0, C_Attribution, NULL, m, e);
643  setlocale(LC_TIME, "");
644  fputs(buf, fp_out);
645  fputc('\n', fp_out);
646 }
#define NONULL(x)
Definition: string2.h:37
WHERE char * C_AttributionLocale
Config: Locale for dates in the attribution message.
Definition: globals.h:100
#define mutt_make_string(BUF, BUFLEN, COLS, S, CTX, M, E)
Definition: hdrline.h:61
WHERE char * C_Attribution
Config: Message to start a reply, "On DATE, PERSON wrote:".
Definition: globals.h:99
+ Here is the caller graph for this function:

◆ mutt_make_post_indent()

void mutt_make_post_indent ( struct Mailbox m,
struct Email e,
FILE *  fp_out 
)

Add suffix to replied email text.

Parameters
mMailbox
eEmail
fp_outFile to write to

Definition at line 654 of file send.c.

655 {
656  if (!C_PostIndentString || !fp_out)
657  return;
658 
659  char buf[256];
660  mutt_make_string(buf, sizeof(buf), 0, C_PostIndentString, NULL, m, e);
661  fputs(buf, fp_out);
662  fputc('\n', fp_out);
663 }
#define mutt_make_string(BUF, BUFLEN, COLS, S, CTX, M, E)
Definition: hdrline.h:61
char * C_PostIndentString
Config: Suffix message to add after reply text.
Definition: send.c:123
+ Here is the caller graph for this function:

◆ include_reply()

static int include_reply ( struct Mailbox m,
struct Email e,
FILE *  fp_out 
)
static

Generate the reply text for an email.

Parameters
mMailbox
eEmail
fp_outFile to write to
Return values
0Success
-1Failure

Definition at line 673 of file send.c.

674 {
675  CopyMessageFlags cmflags =
677  CopyHeaderFlags chflags = CH_DECODE;
678 
679  if ((WithCrypto != 0) && (e->security & SEC_ENCRYPT))
680  {
681  /* make sure we have the user's passphrase before proceeding... */
683  return -1;
684  }
685 
688 
689  mutt_make_attribution(m, e, fp_out);
690 
691  if (!C_Header)
692  cmflags |= MUTT_CM_NOHEADER;
693  if (C_Weed)
694  {
695  chflags |= CH_WEED | CH_REORDER;
696  cmflags |= MUTT_CM_WEED;
697  }
698 
699  mutt_copy_message(fp_out, m, e, cmflags, chflags, 0);
700 
701  mutt_make_post_indent(m, e, fp_out);
702 
703  return 0;
704 }
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Definition: copy.c:810
#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
void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *fp_out)
Add suffix to replied email text.
Definition: send.c:654
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define MUTT_CM_REPLYING
Replying the message.
Definition: copy.h:43
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
#define CH_WEED
Weed the headers?
Definition: copy.h:52
WHERE bool C_Header
Config: Include the message headers in the reply email (Weed applies)
Definition: globals.h:224
#define MUTT_CM_PREFIX
Quote the header and body.
Definition: copy.h:36
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
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:39
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:573
#define MUTT_CM_NOHEADER
Don&#39;t copy the message header.
Definition: copy.h:35
#define WithCrypto
Definition: ncrypt.h:160
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *fp_out)
Add "on DATE, PERSON wrote" header.
Definition: send.c:635
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ choose_default_to()

static const struct AddressList* choose_default_to ( const struct Address from,
const struct Envelope env 
)
static

Pick the best 'to:' value.

Parameters
fromFrom Address
envEnvelope
Return values
ptrAddresses to use

Definition at line 712 of file send.c.

714 {
715  if (!C_ReplySelf && mutt_addr_is_user(from))
716  {
717  /* mail is from the user, assume replying to recipients */
718  return &env->to;
719  }
720  else
721  {
722  return &env->from;
723  }
724 }
bool C_ReplySelf
Config: Really reply to yourself, when replying to your own email.
Definition: send.c:127
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:682
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ default_to()

static int default_to ( struct AddressList *  to,
struct Envelope env,
SendFlags  flags,
int  hmfupto 
)
static

Generate default email addresses.

Parameters
[in,out]to'To' address
[in]envEnvelope to populate
[in]flagsFlags, see SendFlags
[in]hmfuptoIf true, add 'followup-to' address to 'to' address
Return values
0Success
-1Aborted

Definition at line 735 of file send.c.

736 {
737  char prompt[256];
738  const struct Address *from = TAILQ_FIRST(&env->from);
739  const struct Address *reply_to = TAILQ_FIRST(&env->reply_to);
740 
741  if (flags && !TAILQ_EMPTY(&env->mail_followup_to) && (hmfupto == MUTT_YES))
742  {
743  mutt_addrlist_copy(to, &env->mail_followup_to, true);
744  return 0;
745  }
746 
747  /* Exit now if we're setting up the default Cc list for list-reply
748  * (only set if Mail-Followup-To is present and honoured). */
749  if (flags & SEND_LIST_REPLY)
750  return 0;
751 
752  const struct AddressList *default_to = choose_default_to(from, env);
753 
754  if (reply_to)
755  {
756  const bool from_is_reply_to = mutt_addr_cmp(from, reply_to);
757  const bool multiple_reply_to =
758  reply_to && TAILQ_NEXT(TAILQ_FIRST(&env->reply_to), entries);
759  if ((from_is_reply_to && !multiple_reply_to && !reply_to->personal) ||
760  (C_IgnoreListReplyTo && mutt_is_mail_list(reply_to) &&
761  (mutt_addrlist_search(reply_to, &env->to) ||
762  mutt_addrlist_search(reply_to, &env->cc))))
763  {
764  /* If the Reply-To: address is a mailing list, assume that it was
765  * put there by the mailing list, and use the From: address
766  *
767  * We also take the from header if our correspondent has a reply-to
768  * header which is identical to the electronic mail address given
769  * in his From header, and the reply-to has no display-name. */
770  mutt_addrlist_copy(to, &env->from, false);
771  }
772  else if (!(from_is_reply_to && !multiple_reply_to) && (C_ReplyTo != MUTT_YES))
773  {
774  /* There are quite a few mailing lists which set the Reply-To:
775  * header field to the list address, which makes it quite impossible
776  * to send a message to only the sender of the message. This
777  * provides a way to do that. */
778  /* L10N: Asks whether the user respects the reply-to header.
779  If she says no, neomutt will reply to the from header's address instead. */
780  snprintf(prompt, sizeof(prompt), _("Reply to %s%s?"), reply_to->mailbox,
781  multiple_reply_to ? ",..." : "");
782  switch (query_quadoption(C_ReplyTo, prompt))
783  {
784  case MUTT_YES:
785  mutt_addrlist_copy(to, &env->reply_to, false);
786  break;
787 
788  case MUTT_NO:
789  mutt_addrlist_copy(to, default_to, false);
790  break;
791 
792  default:
793  return -1; /* abort */
794  }
795  }
796  else
797  {
798  mutt_addrlist_copy(to, &env->reply_to, false);
799  }
800  }
801  else
802  {
803  mutt_addrlist_copy(to, default_to, false);
804  }
805 
806  return 0;
807 }
#define TAILQ_FIRST(head)
Definition: queue.h:717
struct AddressList mail_followup_to
Email&#39;s &#39;mail-followup-to&#39;.
Definition: envelope.h:63
struct AddressList reply_to
Email&#39;s &#39;reply-to&#39;.
Definition: envelope.h:62
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3340
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
bool mutt_is_mail_list(const struct Address *addr)
Is this the email address of a mailing list?
Definition: hdrline.c:116
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
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
bool C_IgnoreListReplyTo
Config: Ignore the &#39;Reply-To&#39; header when using <reply> on a mailing list.
Definition: send.c:118
static int default_to(struct AddressList *to, struct Envelope *env, SendFlags flags, int hmfupto)
Generate default email addresses.
Definition: send.c:735
unsigned char C_ReplyTo
Config: Address to use as a &#39;Reply-To&#39; header.
Definition: send.c:128
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:90
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
bool mutt_addr_cmp(const struct Address *a, const struct Address *b)
Compare two e-mail addresses.
Definition: address.c:854
static const struct AddressList * choose_default_to(const struct Address *from, const struct Envelope *env)
Pick the best &#39;to:&#39; value.
Definition: send.c:712
char * personal
Real name of address.
Definition: address.h:36
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
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_NEXT(elm, field)
Definition: queue.h:816
#define TAILQ_EMPTY(head)
Definition: queue.h:715
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_fetch_recips()

int mutt_fetch_recips ( struct Envelope out,
struct Envelope in,
SendFlags  flags 
)

Generate recpients for a reply email.

Parameters
outEnvelope to populate
inEnvelope of source email
flagsFlags, see SendFlags
Return values
0Success
-1Failure

Definition at line 817 of file send.c.

818 {
819  enum QuadOption hmfupto = MUTT_ABORT;
820  const struct Address *followup_to = TAILQ_FIRST(&in->mail_followup_to);
821 
822  if ((flags & (SEND_LIST_REPLY | SEND_GROUP_REPLY | SEND_GROUP_CHAT_REPLY)) && followup_to)
823  {
824  char prompt[256];
825  snprintf(prompt, sizeof(prompt), _("Follow-up to %s%s?"), followup_to->mailbox,
826  TAILQ_NEXT(TAILQ_FIRST(&in->mail_followup_to), entries) ? ",..." : "");
827 
828  hmfupto = query_quadoption(C_HonorFollowupTo, prompt);
829  if (hmfupto == MUTT_ABORT)
830  return -1;
831  }
832 
833  if (flags & SEND_LIST_REPLY)
834  {
835  add_mailing_lists(&out->to, &in->to, &in->cc);
836 
837  if (followup_to && (hmfupto == MUTT_YES) &&
838  (default_to(&out->cc, in, flags & SEND_LIST_REPLY, (hmfupto == MUTT_YES)) == MUTT_ABORT))
839  {
840  return -1; /* abort */
841  }
842  }
843  else if (flags & SEND_TO_SENDER)
844  {
845  mutt_addrlist_copy(&out->to, &in->from, false);
846  }
847  else
848  {
849  if (default_to(&out->to, in, flags & (SEND_GROUP_REPLY | SEND_GROUP_CHAT_REPLY),
850  (hmfupto == MUTT_YES)) == -1)
851  return -1; /* abort */
852 
853  if ((flags & (SEND_GROUP_REPLY | SEND_GROUP_CHAT_REPLY)) &&
854  (!followup_to || (hmfupto != MUTT_YES)))
855  {
856  /* if(!mutt_addr_is_user(in->to)) */
857  if (flags & SEND_GROUP_REPLY)
858  mutt_addrlist_copy(&out->cc, &in->to, true);
859  else
860  mutt_addrlist_copy(&out->to, &in->cc, true);
861  mutt_addrlist_copy(&out->cc, &in->cc, true);
862  }
863  }
864  return 0;
865 }
#define SEND_TO_SENDER
Compose new email to sender.
Definition: send.h:100
#define TAILQ_FIRST(head)
Definition: queue.h:717
struct AddressList mail_followup_to
Email&#39;s &#39;mail-followup-to&#39;.
Definition: envelope.h:63
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:3340
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
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
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
static int default_to(struct AddressList *to, struct Envelope *env, SendFlags flags, int hmfupto)
Generate default email addresses.
Definition: send.c:735
unsigned char C_HonorFollowupTo
Config: Honour the &#39;Mail-Followup-To&#39; header when group replying.
Definition: send.c:117
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:90
#define SEND_GROUP_REPLY
Reply to all.
Definition: send.h:89
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:182
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_NEXT(elm, field)
Definition: queue.h:816
#define SEND_GROUP_CHAT_REPLY
Reply to all recipients preserving To/Cc.
Definition: send.h:101
QuadOption
Possible values for a quad-option.
Definition: quad.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_references()

static void add_references ( struct ListHead *  head,
struct Envelope env 
)
static

Add the email's references to a list.

Parameters
headList of references
envEnvelope of message

Definition at line 872 of file send.c.

873 {
874  struct ListNode *np = NULL;
875 
876  struct ListHead *src = !STAILQ_EMPTY(&env->references) ? &env->references : &env->in_reply_to;
877  STAILQ_FOREACH(np, src, entries)
878  {
880  }
881 }
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:65
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * data
String.
Definition: list.h:35
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define STAILQ_EMPTY(head)
Definition: queue.h:346
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
A List node for strings.
Definition: list.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_message_id()

static void add_message_id ( struct ListHead *  head,
struct Envelope env 
)
static

Add the email's message ID to a list.

Parameters
headList of message IDs
envEnvelope of message

Definition at line 888 of file send.c.

889 {
890  if (env->message_id)
891  {
893  }
894 }
char * message_id
Message ID.
Definition: envelope.h:69
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:46
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_fix_reply_recipients()

void mutt_fix_reply_recipients ( struct Envelope env)

Remove duplicate recipients.

Parameters
envEnvelope to fix

Definition at line 900 of file send.c.

901 {
902  if (!C_Metoo)
903  {
904  /* the order is important here. do the CC: first so that if the
905  * the user is the only recipient, it ends up on the TO: field */
906  remove_user(&env->cc, TAILQ_EMPTY(&env->to));
907  remove_user(&env->to, TAILQ_EMPTY(&env->cc) || C_ReplySelf);
908  }
909 
910  /* the CC field can get cluttered, especially with lists */
911  mutt_addrlist_dedupe(&env->to);
912  mutt_addrlist_dedupe(&env->cc);
913  mutt_addrlist_remove_xrefs(&env->to, &env->cc);
914 
915  if (!TAILQ_EMPTY(&env->cc) && TAILQ_EMPTY(&env->to))
916  {
917  TAILQ_SWAP(&env->to, &env->cc, Address, entries);
918  }
919 }
bool C_ReplySelf
Config: Really reply to yourself, when replying to your own email.
Definition: send.c:127
An email address.
Definition: address.h:34
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1318
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
bool C_Metoo
Config: Remove the user&#39;s address from the list of recipients.
Definition: send.c:120
void mutt_addrlist_remove_xrefs(const struct AddressList *a, struct AddressList *b)
Remove cross-references.
Definition: address.c:1354
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_EMPTY(head)
Definition: queue.h:715
static void remove_user(struct AddressList *al, bool leave_only)
Remove any address which matches the current user.
Definition: send.c:163
#define TAILQ_SWAP(head1, head2, type, field)
Definition: queue.h:839
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_make_forward_subject()

void mutt_make_forward_subject ( struct Envelope env,
struct Mailbox m,
struct Email e 
)

Create a subject for a forwarded email.

Parameters
envEnvelope for result
mMailbox
eEmail

Definition at line 927 of file send.c.

928 {
929  if (!env)
930  return;
931 
932  char buf[256];
933 
934  /* set the default subject for the message. */
935  mutt_make_string(buf, sizeof(buf), 0, NONULL(C_ForwardFormat), NULL, m, e);
936  mutt_str_replace(&env->subject, buf);
937 }
#define NONULL(x)
Definition: string2.h:37
char * C_ForwardFormat
Config: printf-like format string to control the subject when forwarding a message.
Definition: send.c:114
#define mutt_make_string(BUF, BUFLEN, COLS, S, CTX, M, E)
Definition: hdrline.h:61
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
char * subject
Email&#39;s subject.
Definition: envelope.h:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_make_misc_reply_headers()

void mutt_make_misc_reply_headers ( struct Envelope env,
struct Envelope curenv 
)

Set subject for a reply.

Parameters
envEnvelope for result
curenvEnvelope of source email

Definition at line 944 of file send.c.

945 {
946  if (!env || !curenv)
947  return;
948 
949  /* This takes precedence over a subject that might have
950  * been taken from a List-Post header. Is that correct? */
951  if (curenv->real_subj)
952  {
953  FREE(&env->subject);
954  env->subject = mutt_mem_malloc(mutt_str_strlen(curenv->real_subj) + 5);
955  sprintf(env->subject, "Re: %s", curenv->real_subj);
956  }
957  else if (!env->subject)
959 }
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
char * subject
Email&#39;s subject.
Definition: envelope.h:66
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define FREE(x)
Definition: memory.h:40
char * C_EmptySubject
Config: Subject to use when replying to an email with none.
Definition: send.c:105
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_add_to_reference_headers()

void mutt_add_to_reference_headers ( struct Envelope env,
struct Envelope curenv 
)

Generate references for a reply email.

Parameters
envEnvelope for result
curenvEnvelope of source email

Definition at line 966 of file send.c.

967 {
968  add_references(&env->references, curenv);
969  add_message_id(&env->references, curenv);
970  add_message_id(&env->in_reply_to, curenv);
971 
972 #ifdef USE_NNTP
973  if (OptNewsSend && C_XCommentTo && !TAILQ_EMPTY(&curenv->from))
975 #endif
976 }
#define TAILQ_FIRST(head)
Definition: queue.h:717
static void add_references(struct ListHead *head, struct Envelope *env)
Add the email&#39;s references to a list.
Definition: send.c:872
static void add_message_id(struct ListHead *head, struct Envelope *env)
Add the email&#39;s message ID to a list.
Definition: send.c:888
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
char * x_comment_to
List of &#39;X-comment-to&#39; fields.
Definition: envelope.h:78
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
WHERE bool C_XCommentTo
Config: (nntp) Add &#39;X-Comment-To&#39; header that contains article author.
Definition: globals.h:292
#define TAILQ_EMPTY(head)
Definition: queue.h:715
WHERE bool OptNewsSend
(pseudo) used to change behavior when posting
Definition: options.h:44
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:155
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_reference_headers()

static void make_reference_headers ( struct EmailList *  el,
struct Envelope env 
)
static

Generate reference headers for an email.

Parameters
elList of source Emails
envEnvelope for result

Definition at line 983 of file send.c.

984 {
985  if (!el || !env || STAILQ_EMPTY(el))
986  return;
987 
988  struct EmailNode *en = STAILQ_FIRST(el);
989  bool single = !STAILQ_NEXT(en, entries);
990 
991  if (!single)
992  {
993  STAILQ_FOREACH(en, el, entries)
994  {
996  }
997  }
998  else
1000 
1001  /* if there's more than entry in In-Reply-To (i.e. message has multiple
1002  * parents), don't generate a References: header as it's discouraged by
1003  * RFC2822, sect. 3.6.4 */
1004  if (!single && !STAILQ_EMPTY(&env->in_reply_to) &&
1005  STAILQ_NEXT(STAILQ_FIRST(&env->in_reply_to), entries))
1006  {
1007  mutt_list_free(&env->references);
1008  }
1009 }
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
struct Envelope * env
Envelope information.
Definition: email.h:89
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
struct Email * email
Email in the list.
Definition: email.h:116
#define STAILQ_EMPTY(head)
Definition: queue.h:346
List of Emails.
Definition: email.h:114
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
#define STAILQ_FIRST(head)
Definition: queue.h:348
void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv)
Generate references for a reply email.
Definition: send.c:966
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ envelope_defaults()

static int envelope_defaults ( struct Envelope env,
struct Mailbox m,
struct EmailList *  el,
SendFlags  flags 
)
static

Fill in some defaults for a new email.

Parameters
envEnvelope for result
mMailbox
elList of Emails to use
flagsFlags, see SendFlags
Return values
0Success
-1Failure

Definition at line 1020 of file send.c.

1022 {
1023  if (!el || STAILQ_EMPTY(el))
1024  return -1;
1025 
1026  struct EmailNode *en = STAILQ_FIRST(el);
1027  bool single = !STAILQ_NEXT(en, entries);
1028 
1029  struct Envelope *curenv = en->email->env;
1030  if (!curenv)
1031  return -1;
1032 
1033  if (flags & (SEND_REPLY | SEND_TO_SENDER))
1034  {
1035 #ifdef USE_NNTP
1036  if ((flags & SEND_NEWS))
1037  {
1038  /* in case followup set Newsgroups: with Followup-To: if it present */
1039  if (!env->newsgroups &&
1040  (mutt_str_strcasecmp(curenv->followup_to, "poster") != 0))
1041  {
1042  env->newsgroups = mutt_str_strdup(curenv->followup_to);
1043  }
1044  }
1045  else
1046 #endif
1047  if (!single)
1048  {
1049  STAILQ_FOREACH(en, el, entries)
1050  {
1051  if (mutt_fetch_recips(env, en->email->env, flags) == -1)
1052  return -1;
1053  }
1054  }
1055  else if (mutt_fetch_recips(env, curenv, flags) == -1)
1056  return -1;
1057 
1058  if ((flags & SEND_LIST_REPLY) && TAILQ_EMPTY(&env->to))
1059  {
1060  mutt_error(_("No mailing lists found"));
1061  return -1;
1062  }
1063 
1064  if (flags & SEND_REPLY)
1065  {
1066  mutt_make_misc_reply_headers(env, curenv);
1067  make_reference_headers(el, env);
1068  }
1069  }
1070  else if (flags & SEND_FORWARD)
1071  {
1072  mutt_make_forward_subject(env, m, en->email);
1073  if (C_ForwardReferences)
1074  make_reference_headers(el, env);
1075  }
1076 
1077  return 0;
1078 }
static void make_reference_headers(struct EmailList *el, struct Envelope *env)
Generate reference headers for an email.
Definition: send.c:983
#define SEND_TO_SENDER
Compose new email to sender.
Definition: send.h:100
#define SEND_FORWARD
Forward email.
Definition: send.h:91
int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags)
Generate recpients for a reply email.
Definition: send.c:817
#define _(a)
Definition: message.h:28
void mutt_make_misc_reply_headers(struct Envelope *env, struct Envelope *curenv)
Set subject for a reply.
Definition: send.c:944
struct Envelope * env
Envelope information.
Definition: email.h:89
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:90
#define SEND_NEWS
Reply to a news article.
Definition: send.h:102
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
#define SEND_REPLY
Reply to sender.
Definition: send.h:88
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
struct Email * email
Email in the list.
Definition: email.h:116
#define mutt_error(...)
Definition: logging.h:84
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
void mutt_make_forward_subject(struct Envelope *env, struct Mailbox *m, struct Email *e)
Create a subject for a forwarded email.
Definition: send.c:927
#define STAILQ_EMPTY(head)
Definition: queue.h:346
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
List of Emails.
Definition: email.h:114
bool C_ForwardReferences
Config: Set the &#39;In-Reply-To&#39; and &#39;References&#39; headers when forwarding a message. ...
Definition: send.c:115
#define TAILQ_EMPTY(head)
Definition: queue.h:715
#define STAILQ_FIRST(head)
Definition: queue.h:348
The header of an Email.
Definition: envelope.h:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generate_body()

static int generate_body ( FILE *  fp_tmp,
struct Email e,
SendFlags  flags,
struct Mailbox m,
struct EmailList *  el 
)
static

Create a new email body.

Parameters
fp_tmpStream for outgoing message
eEmail for outgoing message
flagsCompose mode, see SendFlags
mMailbox
elList of Emails to use
Return values
0Success
-1Error

Definition at line 1090 of file send.c.

1092 {
1093  struct Body *tmp = NULL;
1094  struct EmailNode *en = NULL;
1095  bool single = true;
1096 
1097  if (el)
1098  en = STAILQ_FIRST(el);
1099  if (en)
1100  single = !STAILQ_NEXT(en, entries);
1101 
1102  /* An EmailList is required for replying and forwarding */
1103  if (!el && (flags & (SEND_REPLY | SEND_FORWARD)))
1104  return -1;
1105 
1106  if (flags & SEND_REPLY)
1107  {
1108  enum QuadOption ans =
1109  query_quadoption(C_Include, _("Include message in reply?"));
1110  if (ans == MUTT_ABORT)
1111  return -1;
1112 
1113  if (ans == MUTT_YES)
1114  {
1115  mutt_message(_("Including quoted message..."));
1116  if (single && en)
1117  include_reply(m, en->email, fp_tmp);
1118  else
1119  {
1120  STAILQ_FOREACH(en, el, entries)
1121  {
1122  if (include_reply(m, en->email, fp_tmp) == -1)
1123  {
1124  mutt_error(_("Could not include all requested messages"));
1125  return -1;
1126  }
1127  fputc('\n', fp_tmp);
1128  }
1129  }
1130  }
1131  }
1132  else if (flags & SEND_FORWARD)
1133  {
1134  enum QuadOption ans =
1135  query_quadoption(C_MimeForward, _("Forward as attachment?"));
1136  if (ans == MUTT_YES)
1137  {
1138  struct Body *last = e->content;
1139 
1140  mutt_message(_("Preparing forwarded message..."));
1141 
1142  while (last && last->next)
1143  last = last->next;
1144 
1145  if (single && en)
1146  {
1147  tmp = mutt_make_message_attach(m, en->email, false);
1148  if (last)
1149  last->next = tmp;
1150  else
1151  e->content = tmp;
1152  }
1153  else
1154  {
1155  STAILQ_FOREACH(en, el, entries)
1156  {
1157  tmp = mutt_make_message_attach(m, en->email, false);
1158  if (last)
1159  {
1160  last->next = tmp;
1161  last = tmp;
1162  }
1163  else
1164  {
1165  last = tmp;
1166  e->content = tmp;
1167  }
1168  }
1169  }
1170  }
1171  else if ((ans != MUTT_ABORT) && en)
1172  {
1173  if (mutt_inline_forward(m, e, en->email, fp_tmp) != 0)
1174  return -1;
1175  }
1176  else
1177  return -1;
1178  }
1179  /* if (WithCrypto && (flags & SEND_KEY)) */
1180  else if (((WithCrypto & APPLICATION_PGP) != 0) && (flags & SEND_KEY))
1181  {
1182  struct Body *b = NULL;
1183 
1184  if (((WithCrypto & APPLICATION_PGP) != 0) && !(b = crypt_pgp_make_key_attachment()))
1185  {
1186  return -1;
1187  }
1188 
1189  b->next = e->content;
1190  e->content = b;
1191  }
1192 
1193  mutt_clear_error();
1194 
1195  return 0;
1196 }
struct Body * mutt_make_message_attach(struct Mailbox *m, struct Email *e, bool attach_msg)
Create a message attachment.
Definition: sendlib.c:1517
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:3340
#define mutt_message(...)
Definition: logging.h:83
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
#define SEND_FORWARD
Forward email.
Definition: send.h:91
struct Body * content
List of MIME parts.
Definition: email.h:90
#define _(a)
Definition: message.h:28
struct Body * next
next attachment in the list
Definition: body.h:53
unsigned char C_Include
Config: Include a copy of the email that&#39;s being replied to.
Definition: send.c:119
The body of an email.
Definition: body.h:34
WHERE unsigned char C_MimeForward
Config: Forward a message as a &#39;message/RFC822&#39; MIME part.
Definition: globals.h:187
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:115
#define SEND_KEY
Mail a PGP public key.
Definition: send.h:95
static int include_reply(struct Mailbox *m, struct Email *e, FILE *fp_out)
Generate the reply text for an email.
Definition: send.c:673
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
#define SEND_REPLY
Reply to sender.
Definition: send.h:88
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
struct Body * crypt_pgp_make_key_attachment(void)
Wrapper for CryptModuleSpecs::pgp_make_key_attachment()
Definition: cryptglue.c:296
struct Email * email
Email in the list.
Definition: email.h:116
#define mutt_error(...)
Definition: logging.h:84
List of Emails.
Definition: email.h:114
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:160
int mutt_inline_forward(struct Mailbox *m, struct Email *e_edit, struct Email *e_cur, FILE *out)
Forward attachments, inline.
Definition: send.c:591
QuadOption
Possible values for a quad-option.
Definition: quad.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_set_followup_to()

void mutt_set_followup_to ( struct Envelope env)

Set followup-to field.

Parameters
envEnvelope to modify

Definition at line 1202 of file send.c.

1203 {
1204  /* Only generate the Mail-Followup-To if the user has requested it, and
1205  * it hasn't already been set */
1206 
1207  if (!C_FollowupTo)
1208  return;
1209 #ifdef USE_NNTP
1210  if (OptNewsSend)
1211  {
1212  if (!env->followup_to && env->newsgroups && (strrchr(env->newsgroups, ',')))
1213  env->followup_to = mutt_str_strdup(env->newsgroups);
1214  return;
1215  }
1216 #endif
1217 
1218  if (TAILQ_EMPTY(&env->mail_followup_to))
1219  {
1220  if (mutt_is_list_recipient(false, env))
1221  {
1222  /* this message goes to known mailing lists, so create a proper
1223  * mail-followup-to header */
1224 
1225  mutt_addrlist_copy(&env->mail_followup_to, &env->to, false);
1226  mutt_addrlist_copy(&env->mail_followup_to, &env->cc, true);
1227  }
1228 
1229  /* remove ourselves from the mail-followup-to header */
1230  remove_user(&env->mail_followup_to, false);
1231 
1232  /* If we are not subscribed to any of the lists in question, re-add
1233  * ourselves to the mail-followup-to header. The mail-followup-to header
1234  * generated is a no-op with group-reply, but makes sure list-reply has the
1235  * desired effect. */
1236 
1237  if (!TAILQ_EMPTY(&env->mail_followup_to) &&
1238  !mutt_is_subscribed_list_recipient(false, env))
1239  {
1240  struct AddressList *al = NULL;
1241  if (!TAILQ_EMPTY(&env->reply_to))
1242  al = &env->reply_to;
1243  else if (!TAILQ_EMPTY(&env->from))
1244  al = &env->from;
1245 
1246  if (al)
1247  {
1248  struct Address *a = NULL;
1249  TAILQ_FOREACH_REVERSE(a, al, AddressList, entries)
1250  {
1252  }
1253  }
1254  else
1255  {
1257  }
1258  }
1259 
1261  }
1262 }
struct AddressList mail_followup_to
Email&#39;s &#39;mail-followup-to&#39;.
Definition: envelope.h:63
struct AddressList reply_to
Email&#39;s &#39;reply-to&#39;.
Definition: envelope.h:62
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
An email address.
Definition: address.h:34
bool C_FollowupTo
Config: Add the &#39;Mail-Followup-To&#39; header is generated when sending mail.
Definition: send.c:110
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:706
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1318
#define TAILQ_FOREACH_REVERSE(var, head, headname, field)
Definition: queue.h:739
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
struct Address * mutt_default_from(void)
Get a default &#39;from&#39; Address.
Definition: send.c:1322
void mutt_addrlist_prepend(struct AddressList *al, struct Address *a)
Prepend an Address to an AddressList.
Definition: address.c:1412
char * newsgroups
List of newsgroups.
Definition: envelope.h:75
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
char * followup_to
List of &#39;followup-to&#39; fields.
Definition: envelope.h:77
int mutt_is_subscribed_list_recipient(bool all_addr, struct Envelope *e)
Matches subscribed mailing lists.
Definition: pattern.c:1767
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_EMPTY(head)
Definition: queue.h:715
WHERE bool OptNewsSend
(pseudo) used to change behavior when posting
Definition: options.h:44
static void remove_user(struct AddressList *al, bool leave_only)
Remove any address which matches the current user.
Definition: send.c:163
int mutt_is_list_recipient(bool all_addr, struct Envelope *e)
Matches known mailing lists.
Definition: pattern.c:1779
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_reverse_name()

static void set_reverse_name ( struct AddressList *  al,
struct Envelope env 
)
static

Try to set the 'from' field from the recipients.

Parameters
alAddressList to prepend the found address
envEnvelope to use

Look through the recipients of the message we are replying to, and if we find an address that matches $alternates, we use that as the default from field

Definition at line 1273 of file send.c.

1274 {
1275  struct Address *a = NULL;
1276  if (TAILQ_EMPTY(al))
1277  {
1278  TAILQ_FOREACH(a, &env->to, entries)
1279  {
1280  if (mutt_addr_is_user(a))
1281  {
1283  break;
1284  }
1285  }
1286  }
1287 
1288  if (TAILQ_EMPTY(al))
1289  {
1290  TAILQ_FOREACH(a, &env->cc, entries)
1291  {
1292  if (mutt_addr_is_user(a))
1293  {
1295  break;
1296  }
1297  }
1298  }
1299 
1300  if (TAILQ_EMPTY(al))
1301  {
1302  struct Address *from = TAILQ_FIRST(&env->from);
1303  if (from && mutt_addr_is_user(from))
1304  {
1306  }
1307  }
1308 
1309  if (!TAILQ_EMPTY(al))
1310  {
1311  /* when $reverse_realname is not set, clear the personal name so that it
1312  * may be set via a reply- or send-hook. */
1313  if (!C_ReverseRealname)
1314  FREE(&TAILQ_FIRST(al)->personal);
1315  }
1316 }
#define TAILQ_FIRST(head)
Definition: queue.h:717
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
An email address.
Definition: address.h:34
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:706
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
bool C_ReverseRealname
Config: Set the &#39;From&#39; from the full &#39;To&#39; address the email was sent to.
Definition: send.c:131
char * personal
Real name of address.
Definition: address.h:36
#define FREE(x)
Definition: memory.h:40
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:682
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_EMPTY(head)
Definition: queue.h:715
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
Append an Address to an AddressList.
Definition: address.c:1401
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_default_from()

struct Address* mutt_default_from ( void  )

Get a default 'from' Address.

Return values
ptrNewly allocated Address

Definition at line 1322 of file send.c.

1323 {
1324  /* Note: We let $from override $realname here.
1325  * Is this the right thing to do?
1326  */
1327 
1328  if (C_From)
1329  {
1330  return mutt_addr_copy(C_From);
1331  }
1332  else if (C_UseDomain)
1333  {
1334  struct Address *addr = mutt_addr_new();
1335  mutt_str_asprintf(&addr->mailbox, "%s@%s", NONULL(Username), NONULL(mutt_fqdn(true)));
1336  return addr;
1337  }
1338  else
1339  {
1340  return mutt_addr_create(NULL, Username);
1341  }
1342 }
WHERE char * Username
User&#39;s login name.
Definition: globals.h:54
#define NONULL(x)
Definition: string2.h:37
struct Address * mutt_addr_new(void)
Create a new Address.
Definition: address.c:384
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
Definition: address.c:706
struct Address * mutt_addr_create(const char *personal, const char *mailbox)
Create and populate a new Address.
Definition: address.c:397
WHERE bool C_UseDomain
Config: Qualify local addresses using this domain.
Definition: globals.h:268
WHERE struct Address * C_From
Config: Default &#39;From&#39; address to use, if isn&#39;t otherwise set.
Definition: globals.h:96
const char * mutt_fqdn(bool may_hide_host)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:2537
int mutt_str_asprintf(char **strp, const char *fmt,...)
Definition: string.c:1194
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send_message()

static int send_message ( struct Email e)
static

Send an email.

Parameters
eEmail
Return values
0Success
-1Failure

Definition at line 1350 of file send.c.

1351 {
1352  struct Buffer *tempfile = NULL;
1353  int rc = -1;
1354 #ifdef USE_SMTP
1355  short old_write_bcc;
1356 #endif
1357 
1358  /* Write out the message in MIME form. */
1359  tempfile = mutt_buffer_pool_get();
1360  mutt_buffer_mktemp(tempfile);
1361  FILE *fp_tmp = mutt_file_fopen(mutt_b2s(tempfile), "w");
1362  if (!fp_tmp)
1363  goto cleanup;
1364 
1365 #ifdef USE_SMTP
1366  old_write_bcc = C_WriteBcc;
1367  if (C_SmtpUrl)
1368  C_WriteBcc = false;
1369 #endif
1370 #ifdef MIXMASTER
1372  !STAILQ_EMPTY(&e->chain),
1374 #endif
1375 #ifndef MIXMASTER
1378 #endif
1379 #ifdef USE_SMTP
1380  if (old_write_bcc)
1381  C_WriteBcc = true;
1382 #endif
1383 
1384  fputc('\n', fp_tmp); /* tie off the header. */
1385 
1386  if ((mutt_write_mime_body(e->content, fp_tmp) == -1))
1387  goto cleanup;
1388 
1389  if (mutt_file_fclose(&fp_tmp) != 0)
1390  {
1391  mutt_perror(mutt_b2s(tempfile));
1392  unlink(mutt_b2s(tempfile));
1393  goto cleanup;
1394  }
1395 
1396 #ifdef MIXMASTER
1397  if (!STAILQ_EMPTY(&e->chain))
1398  {
1399  rc = mix_send_message(&e->chain, mutt_b2s(tempfile));
1400  goto cleanup;
1401  }
1402 #endif
1403 
1404 #ifdef USE_NNTP
1405  if (OptNewsSend)
1406  goto sendmail;
1407 #endif
1408 
1409 #ifdef USE_SMTP
1410  if (C_SmtpUrl)
1411  {
1412  rc = mutt_smtp_send(&e->env->from, &e->env->to, &e->env->cc, &e->env->bcc,
1413  mutt_b2s(tempfile), (e->content->encoding == ENC_8BIT));
1414  goto cleanup;
1415  }
1416 #endif
1417 
1418 sendmail:
1419  rc = mutt_invoke_sendmail(&e->env->from, &e->env->to, &e->env->cc, &e->env->bcc,
1420  mutt_b2s(tempfile), (e->content->encoding == ENC_8BIT));
1421 cleanup:
1422  if (fp_tmp)
1423  {
1424  mutt_file_fclose(&fp_tmp);
1425  unlink(mutt_b2s(tempfile));
1426  }
1427  mutt_buffer_pool_release(&tempfile);
1428  return rc;
1429 }
WHERE char * C_SmtpUrl
Config: (smtp) Url of the SMTP server.
Definition: globals.h:144
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:79
WHERE bool C_WriteBcc
Config: Write out the &#39;Bcc&#39; field when preparing to send a mail.
Definition: globals.h:271
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:100
#define mutt_perror(...)
Definition: logging.h:85
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
A normal Email, write full header + MIME headers.
Definition: sendlib.h:60
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
Definition: crypt.c:1082
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:111
struct Body * content
List of MIME parts.
Definition: email.h:90
String manipulation buffer.
Definition: buffer.h:33
8-bit text
Definition: mime.h:50
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:2334
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:2829
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
struct Envelope * env
Envelope information.
Definition: email.h:89
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
#define mutt_b2s(buf)
Definition: buffer.h:41
int mutt_write_mime_body(struct Body *a, FILE *fp)
Write a MIME part.
Definition: sendlib.c:556
int mix_send_message(struct ListHead *chain, const char *tempfile)
Send an email via Mixmaster.
Definition: remailer.c:838
#define STAILQ_EMPTY(head)
Definition: queue.h:346
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
WHERE bool OptNewsSend
(pseudo) used to change behavior when posting
Definition: options.h:44
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:585
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_encode_descriptions()

void mutt_encode_descriptions ( struct Body b,
bool  recurse 
)

rfc2047 encode the content-descriptions

Parameters
bBody of email
recurseIf true, encode children parts

Definition at line 1436 of file send.c.

1437 {
1438  for (struct Body *t = b; t; t = t->next)
1439  {
1440  if (t->description)
1441  {
1442  rfc2047_encode(&t->description, NULL, sizeof("Content-Description:"), C_SendCharset);
1443  }
1444  if (recurse && t->parts)
1445  mutt_encode_descriptions(t->parts, recurse);
1446  }
1447 }
struct Body * next
next attachment in the list
Definition: body.h:53
The body of an email.
Definition: body.h:34
char * C_SendCharset
Config: Character sets for outgoing mail.
Definition: email_globals.c:38
void mutt_encode_descriptions(struct Body *b, bool recurse)
rfc2047 encode the content-descriptions
Definition: send.c:1436
void rfc2047_encode(char **pd, const char *specials, int col, const char *charsets)
RFC-2047-encode a string.
Definition: rfc2047.c:627
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ decode_descriptions()

static void decode_descriptions ( struct Body b)
static

rfc2047 decode them in case of an error

Parameters
bMIME parts to decode

Definition at line 1453 of file send.c.

1454 {
1455  for (struct Body *t = b; t; t = t->next)
1456  {
1457  if (t->description)
1458  {
1459  rfc2047_decode(&t->description);
1460  }
1461  if (t->parts)
1462  decode_descriptions(t->parts);
1463  }
1464 }
struct Body * next
next attachment in the list
Definition: body.h:53
The body of an email.
Definition: body.h:34
void rfc2047_decode(char **pd)
Decode any RFC2047-encoded header fields.
Definition: rfc2047.c:651
static void decode_descriptions(struct Body *b)
rfc2047 decode them in case of an error
Definition: send.c:1453
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fix_end_of_file()

static void fix_end_of_file ( const char *  data)
static

Ensure a file ends with a linefeed.

Parameters
dataName of file to fix

Definition at line 1470 of file send.c.

1471 {
1472  FILE *fp = mutt_file_fopen(data, "a+");
1473  if (!fp)
1474  return;
1475  if (fseek(fp, -1, SEEK_END) >= 0)
1476  {
1477  int c = fgetc(fp);
1478  if (c != '\n')
1479  fputc('\n', fp);
1480  }
1481  mutt_file_fclose(&fp);
1482 }
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
char * data
Pointer to data.
Definition: buffer.h:35
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:585
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_resend_message()

int mutt_resend_message ( FILE *  fp,
struct Context ctx,
struct Email e_cur 
)

Resend an email.

Parameters
fpFile containing email
ctxMailbox
e_curEmail to resend
Return values
0Message was successfully sent
-1Message was aborted or an error occurred
1Message was postponed

Definition at line 1493 of file send.c.

1494 {
1495  struct Email *e_new = email_new();
1496 
1497  if (mutt_prepare_template(fp, ctx->mailbox, e_new, e_cur, true) < 0)
1498  {
1499  email_free(&e_new);
1500  return -1;
1501  }
1502 
1503  if (WithCrypto)
1504  {
1505  /* mutt_prepare_template doesn't always flip on an application bit.
1506  * so fix that here */
1507  if (!(e_new->security & (APPLICATION_SMIME | APPLICATION_PGP)))
1508  {
1509  if (((WithCrypto & APPLICATION_SMIME) != 0) && C_SmimeIsDefault)
1510  e_new->security |= APPLICATION_SMIME;
1511  else if (WithCrypto & APPLICATION_PGP)
1512  e_new->security |= APPLICATION_PGP;
1513  else
1514  e_new->security |= APPLICATION_SMIME;
1515  }
1516 
1518  {
1519  e_new->security |= SEC_OPPENCRYPT;
1521  }
1522  }
1523 
1524  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
1525  el_add_email(&el, e_cur);
1526  int rc = ci_send_message(SEND_RESEND, e_new, NULL, ctx, &el);
1527  emaillist_clear(&el);
1528 
1529  return rc;
1530 }
The envelope/body of an email.
Definition: email.h:37
WHERE bool C_SmimeIsDefault
Config: Use SMIME rather than PGP by default.
Definition: globals.h:282
struct Mailbox * mailbox
Definition: context.h:50
void emaillist_clear(struct EmailList *el)
Drop a private list of Emails.
Definition: email.c:123
int el_add_email(struct EmailList *el, struct Email *e)
Get a list of the selected Emails.
Definition: context.c:403
#define SEND_RESEND
Reply using the current email as a template.
Definition: send.h:96
WHERE bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient&#39;s key is available.
Definition: globals.h:278
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:1868
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:39
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: ncrypt.h:130
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1030
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:322
struct Email * email_new(void)
Create a new Email.
Definition: email.c:68
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:41
#define WithCrypto
Definition: ncrypt.h:160
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:599
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_reply()

static bool is_reply ( struct Email reply,
struct Email orig 
)
static

Is one email a reply to another?

Parameters
replyEmail to test
origOriginal email
Return values
trueIt is a reply
falseIt is not a reply

Definition at line 1539 of file send.c.

1540 {
1541  if (!reply || !reply->env || !orig || !orig->env)
1542  return false;
1543  return mutt_list_find(&orig->env->references, reply->env->message_id) ||
1544  mutt_list_find(&orig->env->in_reply_to, reply->env->message_id);
1545 }
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:82
char * message_id
Message ID.
Definition: envelope.h:69
struct Envelope * env
Envelope information.
Definition: email.h:89
struct ListNode * mutt_list_find(const struct ListHead *h, const char *data)
Find a string in a List.
Definition: list.c:103
struct ListHead references
message references (in reverse order)
Definition: envelope.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search_attach_keyword()

static bool search_attach_keyword ( char *  filename)
static

Search an email for 'attachment' keywords.

Parameters
filenameFilename
Return values
trueIf the regex matches in the email

Search an email for the regex in $abort_noattach_regex. A match might indicate that the user should have attached something.

Note
Quoted lines (as defined by $quote_regex) are ignored

Definition at line 1557 of file send.c.

1558 {
1559  /* Search for the regex in C_AbortNoattachRegex within a file */
1561  !C_QuoteRegex->regex)
1562  {
1563  return false;
1564  }
1565 
1566  FILE *fp_att = mutt_file_fopen(filename, "r");
1567  if (!fp_att)
1568  return false;
1569 
1570  char *inputline = mutt_mem_malloc(1024);
1571  bool found = false;
1572  while (!feof(fp_att))
1573  {
1574  fgets(inputline, 1024, fp_att);
1575  if (!mutt_is_quote_line(inputline, NULL) &&
1577  {
1578  found = true;
1579  break;
1580  }
1581  }
1582  FREE(&inputline);
1583  mutt_file_fclose(&fp_att);
1584  return found;
1585 }
struct Regex * C_AbortNoattachRegex
Config: Regex to match text indicating attachments are expected.
Definition: send.c:92
regex_t * regex
compiled expression
Definition: regex3.h:60
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
Definition: memory.c:90
WHERE struct Regex * C_QuoteRegex
Config: Regex to match quoted text in a reply.
Definition: globals.h:179
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
Definition: regex.c:610
#define FREE(x)
Definition: memory.h:40
int mutt_is_quote_line(char *line, regmatch_t *pmatch)
Is a line of message text a quote?
Definition: pager.c:945
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:585
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save_fcc()

static int save_fcc ( struct Email e,
struct Buffer fcc,
struct Body clear_content,
char *  pgpkeylist,
SendFlags  flags,
char **  finalpath 
)
static

Save an Email to a 'sent mail' folder.

Parameters
[in]eEmail to save
[in]fccFolder to save to (can be comma-separated list)
[in]clear_contentCleartext content of Email
[in]pgpkeylistList of pgp keys
[in]flagsSend mode, see SendFlags
[out]finalpathPath of final folder
Return values
0Success
-1Error

Definition at line 1598 of file send.c.

1600 {
1601  int rc = 0;
1602  struct Body *save_content = NULL;
1603 
1605 
1606  /* Don't save a copy when we are in batch-mode, and the FCC
1607  * folder is on an IMAP server: This would involve possibly lots
1608  * of user interaction, which is not available in batch mode.
1609  *
1610  * Note: A patch to fix the problems with the use of IMAP servers
1611  * from non-curses mode is available from Brendan Cully. However,
1612  * I'd like to think a bit more about this before including it. */
1613 
1614 #ifdef USE_IMAP
1615  if ((flags & SEND_BATCH) && !mutt_buffer_is_empty(fcc) &&
1616  (imap_path_probe(mutt_b2s(fcc), NULL) == MUTT_IMAP))
1617  {
1618  mutt_buffer_reset(fcc);
1619  mutt_error(_("Fcc to an IMAP mailbox is not supported in batch mode"));
1620  return rc;
1621  }
1622 #endif
1623 
1624  if (mutt_buffer_is_empty(fcc) || (mutt_str_strcmp("/dev/null", mutt_b2s(fcc)) == 0))
1625  return rc;
1626 
1627  struct Body *tmpbody = e->content;
1628  struct Body *save_sig = NULL;
1629  struct Body *save_parts = NULL;
1630 
1631  /* Before sending, we don't allow message manipulation because it
1632  * will break message signatures. This is especially complicated by
1633  * Protected Headers. */
1634  if (!C_FccBeforeSend)
1635  {
1636  if ((WithCrypto != 0) && (e->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT)) && C_FccClear)
1637  {
1638  e->content = clear_content;
1641  }
1642 
1643  /* check to see if the user wants copies of all attachments */
1644  if (e->content->type == TYPE_MULTIPART)
1645  {
1646  if ((WithCrypto != 0) && (e->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT)) &&
1647  ((mutt_str_strcmp(e->content->subtype, "encrypted") == 0) ||
1648  (mutt_str_strcmp(e->content->subtype, "signed") == 0)))
1649  {
1650  if ((clear_content->type == TYPE_MULTIPART) &&
1651  (query_quadoption(C_FccAttach, _("Save attachments in Fcc?")) == MUTT_NO))
1652  {
1653  if (!(e->security & SEC_ENCRYPT) && (e->security & SEC_SIGN))
1654  {
1655  /* save initial signature and attachments */
1656  save_sig = e->content->parts->next;
1657  save_parts = clear_content->parts->next;
1658  }
1659 
1660  /* this means writing only the main part */
1661  e->content = clear_content->parts;
1662 
1663  if (mutt_protect(e, pgpkeylist, false) == -1)
1664  {
1665  /* we can't do much about it at this point, so
1666  * fallback to saving the whole thing to fcc */
1667  e->content = tmpbody;
1668  save_sig = NULL;
1669  goto full_fcc;
1670  }
1671 
1672  save_content = e->content;
1673  }
1674  }
1675  else
1676  {
1677  if (query_quadoption(C_FccAttach, _("Save attachments in Fcc?")) == MUTT_NO)
1678  e->content = e->content->parts;
1679  }
1680  }
1681  }
1682 
1683 full_fcc:
1684  if (e->content)
1685  {
1686  /* update received time so that when storing to a mbox-style folder
1687  * the From_ line contains the current time instead of when the
1688  * message was first postponed. */
1689  e->received = mutt_date_epoch();
1690  rc = mutt_write_multiple_fcc(mutt_b2s(fcc), e, NULL, false, NULL, finalpath);
1691  while (rc && !(flags & SEND_BATCH))
1692  {
1693  mutt_clear_error();
1694  int choice = mutt_multi_choice(
1695  /* L10N: Called when saving to $record or Fcc failed after sending.
1696  (r)etry tries the same mailbox again.
1697  alternate (m)ailbox prompts for a different mailbox to try.
1698  (s)kip aborts saving. */
1699  _("Fcc failed. (r)etry, alternate (m)ailbox, or (s)kip?"),
1700  /* L10N: These correspond to the "Fcc failed" multi-choice prompt
1701  (r)etry, alternate (m)ailbox, or (s)kip.
1702  Any similarity to famous leaders of the FSF is coincidental. */
1703  _("rms"));
1704  switch (choice)
1705  {
1706  case 2: /* alternate (m)ailbox */
1707  /* L10N: This is the prompt to enter an "alternate (m)ailbox" when the
1708  initial Fcc fails. */
1709  rc = mutt_buffer_enter_fname(_("Fcc mailbox"), fcc, true);
1710  if ((rc == -1) || mutt_buffer_is_empty(fcc))
1711  {
1712  rc = 0;
1713  break;
1714  }
1715  /* fall through */
1716 
1717  case 1: /* (r)etry */
1718  rc = mutt_write_multiple_fcc(mutt_b2s(fcc), e, NULL, false, NULL, finalpath);
1719  break;
1720 
1721  case -1: /* abort */
1722  case 3: /* (s)kip */
1723  rc = 0;
1724  break;
1725  }
1726  }
1727  }
1728 
1729  if (!C_FccBeforeSend)
1730  {
1731  e->content = tmpbody;
1732 
1733  if ((WithCrypto != 0) && save_sig)
1734  {
1735  /* cleanup the second signature structures */
1736  if (save_content->parts)
1737  {
1738  mutt_body_free(&save_content->parts->next);
1739  save_content->parts = NULL;
1740  }
1741  mutt_body_free(&save_content);
1742 
1743  /* restore old signature and attachments */
1744  e->content->parts->next = save_sig;
1745  e->content->parts->parts->next = save_parts;
1746  }
1747  else if ((WithCrypto != 0) && save_content)
1748  {
1749  /* destroy the new encrypted body. */
1750  mutt_body_free(&save_content);
1751  }
1752  }
1753 
1754  return 0;
1755 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:410
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2430
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3340
bool C_FccBeforeSend
Config: Save FCCs before sending the message.
Definition: send.c:108
struct Body * content
List of MIME parts.
Definition: email.h:90
#define _(a)
Definition: message.h:28
struct Body * next
next attachment in the list
Definition: body.h:53
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
The body of an email.
Definition: body.h:34
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:115
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:3211
char * subtype
content-type subtype
Definition: body.h:37
#define mutt_b2s(buf)
Definition: buffer.h:41
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:862
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
unsigned char C_FccAttach
Config: Save send message with all their attachments.
Definition: send.c:107
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
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
bool C_FccClear
Config: Save sent messages unencrypted and unsigned.
Definition: send.c:109
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:39
unsigned int type
content-type primary type
Definition: body.h:65
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:343
#define mutt_error(...)
Definition: logging.h:84
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:52
#define WithCrypto
Definition: ncrypt.h:160
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
#define mutt_buffer_enter_fname(prompt, fname, mailbox)
Definition: curs_lib.h:87
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:82
#define SEND_BATCH
Send email in batch mode (without user interaction)
Definition: send.h:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ postpone_message()

static int postpone_message ( struct Email e_post,
struct Email e_cur,
const char *  fcc,
SendFlags  flags 
)
static

Save an Email for another day.

Parameters
e_postEmail to postpone
e_curCurrent Email in the index
fccFolder for 'sent mail'
flagsSend mode, see SendFlags
Return values
0Success
-1Error

Definition at line 1766 of file send.c.

1768 {
1769  char *pgpkeylist = NULL;
1770  char *encrypt_as = NULL;
1771  struct Body *clear_content = NULL;
1772 
1773  if (!C_Postponed)
1774  {
1775  mutt_error(_("Can't postpone. $postponed is unset"));
1776  return -1;
1777  }
1778 
1779  if (e_post->content->next)
1780  e_post->content = mutt_make_multipart(e_post->content);
1781 
1782  mutt_encode_descriptions(e_post->content, true);
1783 
1784  if ((WithCrypto != 0) && C_PostponeEncrypt &&
1785  (e_post->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)))
1786  {
1787  if (((WithCrypto & APPLICATION_PGP) != 0) && (e_post->security & APPLICATION_PGP))
1788  encrypt_as = C_PgpDefaultKey;
1789  else if (((WithCrypto & APPLICATION_SMIME) != 0) && (e_post->security & APPLICATION_SMIME))
1790  encrypt_as = C_SmimeDefaultKey;
1791  if (!encrypt_as)
1792  encrypt_as = C_PostponeEncryptAs;
1793 
1794 #ifdef USE_AUTOCRYPT
1795  if (e_post->security & SEC_AUTOCRYPT)
1796  {
1798  {
1799  e_post->content = mutt_remove_multipart(e_post->content);
1800  decode_descriptions(e_post->content);
1801  return -1;
1802  }
1803  encrypt_as = AutocryptDefaultKey;
1804  }
1805 #endif
1806 
1807  if (encrypt_as)
1808  {
1809  pgpkeylist = mutt_str_strdup(encrypt_as);
1810  clear_content = e_post->content;
1811  if (mutt_protect(e_post, pgpkeylist, true) == -1)
1812  {
1813  FREE(&pgpkeylist);
1814  e_post->content = mutt_remove_multipart(e_post->content);
1815  decode_descriptions(e_post->content);
1816  return -1;
1817  }
1818 
1819  FREE(&pgpkeylist);
1820 
1821  mutt_encode_descriptions(e_post->content, false);
1822  }
1823  }
1824 
1825  /* make sure the message is written to the right part of a maildir
1826  * postponed folder. */
1827  e_post->read = false;
1828  e_post->old = false;
1829 
1830  mutt_prepare_envelope(e_post->env, false);
1831  mutt_env_to_intl(e_post->env, NULL, NULL); /* Handle bad IDNAs the next time. */
1832 
1833  if (mutt_write_fcc(NONULL(C_Postponed), e_post,
1834  (e_cur && (flags & SEND_REPLY)) ? e_cur->env->message_id : NULL,
1835  true, fcc, NULL) < 0)
1836  {
1837  if (clear_content)
1838  {
1839  mutt_body_free(&e_post->content);
1840  e_post->content = clear_content;
1841  }
1842  mutt_env_free(&e_post->content->mime_headers); /* protected headers */
1843  e_post->content = mutt_remove_multipart(e_post->content);
1844  decode_descriptions(e_post->content);
1845  mutt_unprepare_envelope(e_post->env);
1846  return -1;
1847  }
1848 
1850 
1851  if (clear_content)
1852  mutt_body_free(&clear_content);
1853 
1854  return 0;
1855 }
char * C_PostponeEncryptAs
Config: Fallback encryption key for postponed messages.
Definition: send.c:125
#define NONULL(x)
Definition: string2.h:37
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: sendlib.c:1773
WHERE char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
Definition: globals.h:168
WHERE char * AutocryptDefaultKey
Autocrypt default key id (used for postponing messages)
Definition: globals.h:90
struct Body * content
List of MIME parts.
Definition: email.h:90
bool C_PostponeEncrypt
Config: Self-encrypt postponed messages.
Definition: send.c:124
#define _(a)
Definition: message.h:28
struct Body * next
next attachment in the list
Definition: body.h:53
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:309
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, bool post, const char *fcc, char **finalpath)
Write email to FCC mailbox.
Definition: sendlib.c:3258
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:3007
bool read
Email is read.
Definition: email.h:51
char * message_id
Message ID.
Definition: envelope.h:69
bool old
Email is seen, but unread.
Definition: email.h:50
struct Envelope * env
Envelope information.
Definition: email.h:89
static void decode_descriptions(struct Body *b)
rfc2047 decode them in case of an error
Definition: send.c:1453
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
Definition: sendlib.c:1747
int mutt_autocrypt_set_sign_as_default_key(struct Email *e)
Set the Autocrypt default key for signing.
Definition: autocrypt.c:674
void mutt_unprepare_envelope(struct Envelope *env)
Undo the encodings of mutt_prepare_envelope()
Definition: sendlib.c:3046
void mutt_encode_descriptions(struct Body *b, bool recurse)
rfc2047 encode the content-descriptions
Definition: send.c:1436
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
int mutt_protect(struct Email *e, char *keylist, bool postpone)
Encrypt and/or sign a message.
Definition: crypt.c:172
void mutt_update_num_postponed(void)
Force the update of the number of postponed messages.
Definition: postpone.c:200
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:39
#define SEND_REPLY
Reply to sender.
Definition: send.h:88
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
#define mutt_error(...)
Definition: logging.h:84
WHERE char * C_PgpDefaultKey
Config: Default key to use for PGP operations.
Definition: globals.h:164
#define FREE(x)
Definition: memory.h:40
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
WHERE char * C_Postponed
Config: Folder to store postponed messages.
Definition: globals.h:136
#define WithCrypto
Definition: ncrypt.h:160
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ci_send_message()

int ci_send_message ( SendFlags  flags,
struct Email e_templ,
const char *  tempfile,
struct Context ctx,
struct EmailList *  el 
)

Send an email.

Parameters
flagsSend mode, see SendFlags
e_templTemplate to use for new message
tempfileFile specified by -i or -H
ctxCurrent mailbox
elList of Emails to send
Return values
0Message was successfully sent
-1Message was aborted or an error occurred
1Message was postponed

Definition at line 1868 of file send.c.

1870 {
1871  char buf[1024];
1872  struct Buffer fcc = mutt_buffer_make(0); /* where to copy this message */
1873  FILE *fp_tmp = NULL;
1874  struct Body *pbody = NULL;
1875  int i;
1876  bool free_clear_content = false;
1877 
1878  struct Body *clear_content = NULL;
1879  char *pgpkeylist = NULL;
1880  /* save current value of "pgp_sign_as" and "smime_default_key" */
1881  char *pgp_signas = NULL;
1882  char *smime_signas = NULL;
1883  const char *tag = NULL;
1884  char *err = NULL;
1885  char *ctype = NULL;
1886  char *finalpath = NULL;
1887  struct EmailNode *en = NULL;
1888  struct Email *e_cur = NULL;
1889 
1890  if (el)
1891  en = STAILQ_FIRST(el);
1892  if (en)
1893  e_cur = STAILQ_NEXT(en, entries) ? NULL : en->email;
1894 
1895  int rc = -1;
1896 
1897 #ifdef USE_NNTP
1898  if (flags & SEND_NEWS)
1899  OptNewsSend = true;
1900  else
1901  OptNewsSend = false;
1902 #endif
1903 
1904  if (!flags && !e_templ && (C_Recall != MUTT_NO) &&
1905  mutt_num_postponed(ctx ? ctx->mailbox : NULL, true))
1906  {
1907  /* If the user is composing a new message, check to see if there
1908  * are any postponed messages first. */
1909  enum QuadOption ans =
1910  query_quadoption(C_Recall, _("Recall postponed message?"));
1911  if (ans == MUTT_ABORT)
1912  return rc;
1913 
1914  if (ans == MUTT_YES)
1915  flags |= SEND_POSTPONED;
1916  }
1917 
1918  /* Allocate the buffer due to the long lifetime, but
1919  * pre-resize it to ensure there are no NULL data field issues */
1920  mutt_buffer_alloc(&fcc, 1024);
1921 
1922  if (flags & SEND_POSTPONED)
1923  {
1925  pgp_signas = mutt_str_strdup(C_PgpSignAs);
1927  smime_signas = mutt_str_strdup(C_SmimeSignAs);
1928  }
1929 
1930  /* Delay expansion of aliases until absolutely necessary--shouldn't
1931  * be necessary unless we are prompting the user or about to execute a
1932  * send-hook. */
1933 
1934  if (!e_templ)
1935  {
1936  e_templ = email_new();
1937 
1938  if (flags == SEND_POSTPONED)
1939  {
1940  rc = mutt_get_postponed(ctx, e_templ, &e_cur, &fcc);
1941  if (rc < 0)
1942  {
1943  flags = SEND_POSTPONED;
1944  goto cleanup;
1945  }
1946  flags = rc;
1947 #ifdef USE_NNTP
1948  /* If postponed message is a news article, it have
1949  * a "Newsgroups:" header line, then set appropriate flag. */
1950  if (e_templ->env->newsgroups)
1951  {
1952  flags |= SEND_NEWS;
1953  OptNewsSend = true;
1954  }
1955  else
1956  {
1957  flags &= ~SEND_NEWS;
1958  OptNewsSend = false;
1959  }
1960 #endif
1961  }
1962 
1963  if (flags & (SEND_POSTPONED | SEND_RESEND))
1964  {
1965  fp_tmp = mutt_file_fopen(e_templ->content->filename, "a+");
1966  if (!fp_tmp)
1967  {
1968  mutt_perror(e_templ->content->filename);
1969  goto cleanup;
1970  }
1971  }
1972 
1973  if (!e_templ->env)
1974  e_templ->env = mutt_env_new();
1975  }
1976 
1977  /* Parse and use an eventual list-post header */
1978  if ((flags & SEND_LIST_REPLY) && e_cur && e_cur->env && e_cur->env->list_post)
1979  {
1980  /* Use any list-post header as a template */
1981  mutt_parse_mailto(e_templ->env, NULL, e_cur->env->list_post);
1982  /* We don't let them set the sender's address. */
1983  mutt_addrlist_clear(&e_templ->env->from);
1984  }
1985 
1986  if (!(flags & (SEND_KEY | SEND_POSTPONED | SEND_RESEND)))
1987  {
1988  /* When SEND_DRAFT_FILE is set, the caller has already
1989  * created the "parent" body structure. */
1990  if (!(flags & SEND_DRAFT_FILE))
1991  {
1992  pbody = mutt_body_new();
1993  pbody->next = e_templ->content; /* don't kill command-line attachments */
1994  e_templ->content = pbody;
1995 
1996  ctype = mutt_str_strdup(C_ContentType);
1997  if (!ctype)
1998  ctype = mutt_str_strdup("text/plain");
1999  mutt_parse_content_type(ctype, e_templ->content);
2000  FREE(&ctype);
2001  e_templ->content->unlink = true;
2002  e_templ->content->use_disp = false;
2003  e_templ->content->disposition = DISP_INLINE;
2004 
2005  if (tempfile)
2006  {
2007  fp_tmp = mutt_file_fopen(tempfile, "a+");
2008  e_templ->content->filename = mutt_str_strdup(tempfile);
2009  }
2010  else
2011  {
2012  mutt_mktemp(buf, sizeof(buf));
2013  fp_tmp = mutt_file_fopen(buf, "w+");
2014  e_templ->content->filename = mutt_str_strdup(buf);
2015  }
2016  }
2017  else
2018  fp_tmp = mutt_file_fopen(e_templ->content->filename, "a+");
2019 
2020  if (!fp_tmp)
2021  {
2022  mutt_debug(LL_DEBUG1, "can't create tempfile %s (errno=%d)\n",
2023  e_templ->content->filename, errno);
2024  mutt_perror(e_templ->content->filename);
2025  goto cleanup;
2026  }
2027  }
2028 
2029  /* this is handled here so that the user can match ~f in send-hook */
2030  if (e_cur && C_ReverseName && !(flags & (SEND_POSTPONED | SEND_RESEND)))
2031  {
2032  /* We shouldn't have to worry about alias expansion here since we are
2033  * either replying to a real or postponed message, therefore no aliases
2034  * should exist since the user has not had the opportunity to add
2035  * addresses to the list. We just have to ensure the postponed messages
2036  * have their aliases expanded. */
2037 
2038  if (!TAILQ_EMPTY(&e_templ->env->from))
2039  {
2040  mutt_debug(LL_DEBUG5, "e_templ->env->from before set_reverse_name: %s\n",
2041  TAILQ_FIRST(&e_templ->env->from)->mailbox);
2042  mutt_addrlist_clear(&e_templ->env->from);
2043  }
2044  set_reverse_name(&e_templ->env->from, e_cur->env);
2045  }
2046  if (e_cur && C_ReplyWithXorig && !(flags & (SEND_POSTPONED | SEND_RESEND | SEND_FORWARD)))
2047  {
2048  /* We shouldn't have to worry about freeing 'e_templ->env->from' before
2049  * setting it here since this code will only execute when doing some
2050  * sort of reply. The pointer will only be set when using the -H command
2051  * line option.
2052  *
2053  * If there is already a from address recorded in 'e_templ->env->from',
2054  * then it theoretically comes from C_ReverseName handling, and we don't use
2055  * the 'X-Orig-To header'. */
2056  if (!TAILQ_EMPTY(&e_cur->env->x_original_to) && TAILQ_EMPTY(&e_templ->env->from))
2057  {
2058  mutt_addrlist_copy(&e_templ->env->from, &e_cur->env->x_original_to, false);
2059  mutt_debug(LL_DEBUG5, "e_templ->env->from extracted from X-Original-To: header: %s\n",
2060  TAILQ_FIRST(&e_templ->env->from)->mailbox);
2061  }
2062  }
2063 
2064  if (!(flags & (SEND_POSTPONED | SEND_RESEND)) &&
2065  !((flags & SEND_DRAFT_FILE) && C_ResumeDraftFiles))
2066  {
2067  if ((flags & (SEND_REPLY | SEND_FORWARD | SEND_TO_SENDER)) && ctx &&
2068  (envelope_defaults(e_templ->env, ctx->mailbox, el, flags) == -1))
2069  {
2070  goto cleanup;
2071  }
2072 
2073  if (C_Hdrs)
2074  process_user_recips(e_templ->env);
2075 
2076  /* Expand aliases and remove duplicates/crossrefs */
2077  mutt_expand_aliases_env(e_templ->env);
2078 
2079  if (flags & SEND_REPLY)
2080  mutt_fix_reply_recipients(e_templ->env);
2081 
2082 #ifdef USE_NNTP
2083  if ((flags & SEND_NEWS) && ctx && (ctx->mailbox->magic == MUTT_NNTP) &&
2084  !e_templ->env->newsgroups)
2085  {
2086  e_templ->env->newsgroups =
2087  mutt_str_strdup(((struct NntpMboxData *) ctx->mailbox->mdata)->group);
2088  }
2089 #endif
2090 
2091  if (!(flags & (SEND_MAILX | SEND_BATCH)) &&
2092  !(C_Autoedit && C_EditHeaders) && !((flags & SEND_REPLY) && C_FastReply))
2093  {
2094  if (edit_envelope(e_templ->env, flags) == -1)
2095  goto cleanup;
2096  }
2097 
2098  /* the from address must be set here regardless of whether or not
2099  * $use_from is set so that the '~P' (from you) operator in send-hook
2100  * patterns will work. if $use_from is unset, the from address is killed
2101  * after send-hooks are evaluated */
2102 
2103  const bool killfrom = TAILQ_EMPTY(&e_templ->env->from);
2104  if (killfrom)
2105  {
2107  }
2108 
2109  if ((flags & SEND_REPLY) && e_cur)
2110  {
2111  /* change setting based upon message we are replying to */
2112  mutt_message_hook(ctx ? ctx->mailbox : NULL, e_cur, MUTT_REPLY_HOOK);
2113 
2114  /* set the replied flag for the message we are generating so that the
2115  * user can use ~Q in a send-hook to know when reply-hook's are also
2116  * being used. */
2117  e_templ->replied = true;
2118  }
2119 
2120  /* change settings based upon recipients */
2121 
2122  mutt_message_hook(NULL, e_templ, MUTT_SEND_HOOK);
2123 
2124  /* Unset the replied flag from the message we are composing since it is
2125  * no longer required. This is done here because the FCC'd copy of
2126  * this message was erroneously get the 'R'eplied flag when stored in
2127  * a maildir-style mailbox. */
2128  e_templ->replied = false;
2129 
2130  /* $use_from and/or $from might have changed in a send-hook */
2131  if (killfrom)
2132  {
2133  mutt_addrlist_clear(&e_templ->env->from);
2134  if (C_UseFrom && !(flags & (SEND_POSTPONED | SEND_RESEND)))
2136  }
2137 
2138  if (C_Hdrs)
2139  process_user_header(e_templ->env);
2140 
2141  if (flags & SEND_BATCH)
2142  mutt_file_copy_stream(stdin, fp_tmp);
2143 
2144  if (C_SigOnTop && !(flags & (SEND_MAILX | SEND_KEY | SEND_BATCH)) &&
2145  C_Editor && (mutt_str_strcmp(C_Editor, "builtin") != 0))
2146  {
2147  append_signature(fp_tmp);
2148  }
2149 
2150  /* include replies/forwarded messages, unless we are given a template */
2151  if (!tempfile && (ctx || !(flags & (SEND_REPLY | SEND_FORWARD))) &&
2152  (generate_body(fp_tmp, e_templ, flags, ctx ? ctx->mailbox : NULL, el) == -1))
2153  {
2154  goto cleanup;
2155  }
2156 
2157  if (!C_SigOnTop && !(flags & (SEND_MAILX | SEND_KEY | SEND_BATCH)) &&
2158  C_Editor && (mutt_str_strcmp(C_Editor, "builtin") != 0))
2159  {
2160  append_signature(fp_tmp);
2161  }
2162  }
2163 
2164  /* Only set format=flowed for new messages. postponed/resent/draftfiles
2165  * should respect the original email.
2166  *
2167  * This is set here so that send-hook can be used to turn the option on. */
2168  if (!(flags & (SEND_KEY | SEND_POSTPONED | SEND_RESEND | SEND_DRAFT_FILE)))
2169  {
2170  if (C_TextFlowed && (e_templ->content->type == TYPE_TEXT) &&
2171  (mutt_str_strcasecmp(e_templ->content->subtype, "plain") == 0))
2172  {
2173  mutt_param_set(&e_templ->content->parameter, "format", "flowed");
2174  }
2175  }
2176 
2177  /* This hook is even called for postponed messages, and can, e.g., be
2178  * used for setting the editor, the sendmail path, or the
2179  * envelope sender. */
2180  mutt_message_hook(NULL, e_templ, MUTT_SEND2_HOOK);
2181 
2182  /* wait until now to set the real name portion of our return address so
2183  * that $realname can be set in a send-hook */
2184  {
2185  struct Address *from = TAILQ_FIRST(&e_templ->env->from);
2186  if (from && !from->personal && !(flags & (SEND_RESEND | SEND_POSTPONED)))
2188  }
2189 
2190  if (!(((WithCrypto & APPLICATION_PGP) != 0) && (flags & SEND_KEY)))
2191  mutt_file_fclose(&fp_tmp);
2192 
2193  if (flags & SEND_MAILX)
2194  {
2195  if (mutt_builtin_editor(e_templ->content->filename, e_templ, e_cur) == -1)
2196  goto cleanup;
2197  }
2198  else if (!(flags & SEND_BATCH))
2199  {
2200  struct stat st;
2201  time_t mtime = mutt_file_decrease_mtime(e_templ->content->filename, NULL);
2202 
2203  mutt_update_encoding(e_templ->content);
2204 
2205  /* Select whether or not the user's editor should be called now. We
2206  * don't want to do this when:
2207  * 1) we are sending a key/cert
2208  * 2) we are forwarding a message and the user doesn't want to edit it.
2209  * This is controlled by the quadoption $forward_edit. However, if
2210  * both $edit_headers and $autoedit are set, we want to ignore the
2211  * setting of $forward_edit because the user probably needs to add the
2212  * recipients. */
2213  if (!(flags & SEND_KEY) &&
2214  (((flags & SEND_FORWARD) == 0) || (C_EditHeaders && C_Autoedit) ||
2215  (query_quadoption(C_ForwardEdit, _("Edit forwarded message?")) == MUTT_YES)))
2216  {
2217  /* If the this isn't a text message, look for a mailcap edit command */
2218  if (mutt_needs_mailcap(e_templ->content))
2219  {
2220  if (!mutt_edit_attachment(e_templ->content))
2221  goto cleanup;
2222  }
2223  else if (!C_Editor || (mutt_str_strcmp("builtin", C_Editor) == 0))
2224  mutt_builtin_editor(e_templ->content->filename, e_templ, e_cur);
2225  else if (C_EditHeaders)
2226  {
2227  mutt_env_to_local(e_templ->env);
2228  mutt_edit_headers(C_Editor, e_templ->content->filename, e_templ, &fcc);
2229  mutt_env_to_intl(e_templ->env, NULL, NULL);
2230  }
2231  else
2232  {
2234  if (stat(e_templ->content->filename, &st) == 0)
2235  {
2236  if (mtime != st.st_mtime)
2237  fix_end_of_file(e_templ->content->filename);
2238  }
2239  else
2240  mutt_perror(e_templ->content->filename);
2241  }
2242 
2243  mutt_message_hook(NULL, e_templ, MUTT_SEND2_HOOK);
2244  }
2245 
2246  if (!(flags & (SEND_POSTPONED | SEND_FORWARD | SEND_KEY | SEND_RESEND | SEND_DRAFT_FILE)))
2247  {
2248  if (stat(e_templ->content->filename, &st) == 0)
2249  {
2250  /* if the file was not modified, bail out now */
2251  if ((mtime == st.st_mtime) && !e_templ->content->next &&
2253  _("Abort unmodified message?")) == MUTT_YES))
2254  {
2255  mutt_message(_("Aborted unmodified message"));
2256  goto cleanup;
2257  }
2258  }
2259  else
2260  mutt_perror(e_templ->content->filename);
2261  }
2262  }
2263 
2264  /* Set the message security unless:
2265  * 1) crypto support is not enabled (WithCrypto==0)
2266  * 2) pgp: header field was present during message editing with $edit_headers (e_templ->security != 0)
2267  * 3) we are resending a message
2268  * 4) we are recalling a postponed message (don't override the user's saved settings)
2269  * 5) we are in mailx mode
2270  * 6) we are in batch mode
2271  *
2272  * This is done after allowing the user to edit the message so that security
2273  * settings can be configured with send2-hook and $edit_headers. */
2274  if ((WithCrypto != 0) && (e_templ->security == 0) &&
2275  !(flags & (SEND_BATCH | SEND_MAILX | SEND_POSTPONED | SEND_RESEND)))
2276  {
2277  if (
2278 #ifdef USE_AUTOCRYPT
2280 #else
2281  0
2282 #endif
2283  && e_cur && (e_cur->security & SEC_AUTOCRYPT))
2284  {
2286  }
2287  else
2288  {
2289  if (C_CryptAutosign)
2290  e_templ->security |= SEC_SIGN;
2291  if (C_CryptAutoencrypt)
2292  e_templ->security |= SEC_ENCRYPT;
2293  if (C_CryptReplyencrypt && e_cur && (e_cur->security & SEC_ENCRYPT))
2294  e_templ->security |= SEC_ENCRYPT;
2295  if (C_CryptReplysign && e_cur && (e_cur->security & SEC_SIGN))
2296  e_templ->security |= SEC_SIGN;
2297  if (C_CryptReplysignencrypted && e_cur && (e_cur->security & SEC_ENCRYPT))
2298  e_templ->security |= SEC_SIGN;
2299  if (((WithCrypto & APPLICATION_PGP) != 0) &&
2301  {
2302  if (C_PgpAutoinline)
2303  e_templ->security |= SEC_INLINE;
2304  if (C_PgpReplyinline && e_cur && (e_cur->security & SEC_INLINE))
2305  e_templ->security |= SEC_INLINE;
2306  }
2307  }
2308 
2309  if (e_templ->security || C_CryptOpportunisticEncrypt)
2310  {
2311  /* When replying / forwarding, use the original message's
2312  * crypto system. According to the documentation,
2313  * smime_is_default should be disregarded here.
2314  *
2315  * Problem: At least with forwarding, this doesn't really
2316  * make much sense. Should we have an option to completely
2317  * disable individual mechanisms at run-time? */
2318  if (e_cur)
2319  {
2320  if (((WithCrypto & APPLICATION_PGP) != 0) && C_CryptAutopgp &&
2321  (e_cur->security & APPLICATION_PGP))
2322  {
2323  e_templ->security |= APPLICATION_PGP;
2324  }
2325  else if (((WithCrypto & APPLICATION_SMIME) != 0) && C_CryptAutosmime &&
2326  (e_cur->security & APPLICATION_SMIME))
2327  {
2328  e_templ->security |= APPLICATION_SMIME;
2329  }
2330  }
2331 
2332  /* No crypto mechanism selected? Use availability + smime_is_default
2333  * for the decision. */
2334  if (!(e_templ->security & (APPLICATION_SMIME | APPLICATION_PGP)))
2335  {
2336  if (((WithCrypto & APPLICATION_SMIME) != 0) && C_CryptAutosmime && C_SmimeIsDefault)
2337  {
2338  e_templ->security |= APPLICATION_SMIME;
2339  }
2340  else if (((WithCrypto & APPLICATION_PGP) != 0) && C_CryptAutopgp)
2341  {
2342  e_templ->security |= APPLICATION_PGP;
2343  }
2344  else if (((WithCrypto & APPLICATION_SMIME) != 0) && C_CryptAutosmime)
2345  {
2346  e_templ->security |= APPLICATION_SMIME;
2347  }
2348  }
2349  }
2350 
2351  /* opportunistic encrypt relies on SMIME or PGP already being selected */
2353  {
2354  /* If something has already enabled encryption, e.g. C_CryptAutoencrypt
2355  * or C_CryptReplyencrypt, then don't enable opportunistic encrypt for
2356  * the message. */
2357  if (!(e_templ->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)))
2358  {
2359  e_templ->security |= SEC_OPPENCRYPT;
2360  crypt_opportunistic_encrypt(e_templ);
2361  }
2362  }
2363 
2364  /* No permissible mechanisms found. Don't sign or encrypt. */
2365  if (!(e_templ->security & (APPLICATION_SMIME | APPLICATION_PGP)))
2366  e_templ->security = SEC_NO_FLAGS;
2367  }
2368 
2369  /* Deal with the corner case where the crypto module backend is not available.
2370  * This can happen if configured without pgp/smime and with gpgme, but
2371  * $crypt_use_gpgme is unset. */
2372  if (e_templ->security && !crypt_has_module_backend(e_templ->security))
2373  {
2374  mutt_error(_(
2375  "No crypto backend configured. Disabling message security setting."));
2376  e_templ->security = SEC_NO_FLAGS;
2377  }
2378 
2379  /* specify a default fcc. if we are in batchmode, only save a copy of
2380  * the message if the value of $copy is yes or ask-yes */
2381 
2382  if (mutt_buffer_is_empty(&fcc) && !(flags & SEND_POSTPONED_FCC) &&
2383  (!(flags & SEND_BATCH) || (C_Copy & 0x1)))
2384  {
2385  /* set the default FCC */
2386  const bool killfrom = TAILQ_EMPTY(&e_templ->env->from);
2387  if (killfrom)
2388  {
2390  }
2391  mutt_select_fcc(&fcc, e_templ);
2392  if (killfrom)
2393  {
2394  mutt_addrlist_clear(&e_templ->env->from);
2395  }
2396  }
2397 
2398  mutt_rfc3676_space_stuff(e_templ);
2399 
2400  mutt_update_encoding(e_templ->content);
2401 
2402  if (!(flags & (SEND_MAILX | SEND_BATCH)))
2403  {
2404  main_loop:
2405 
2407  i = mutt_compose_menu(e_templ, &fcc, e_cur,
2409  if (i == -1)
2410  {
2411 /* abort */
2412 #ifdef USE_NNTP
2413  if (flags & SEND_NEWS)
2414  mutt_message(_("Article not posted"));
2415  else
2416 #endif
2417  mutt_message(_("Mail not sent"));
2418  goto cleanup;
2419  }
2420  else if (i == 1)
2421  {
2422  if (postpone_message(e_templ, e_cur, mutt_b2s(&fcc), flags) != 0)
2423  goto main_loop;
2424  mutt_message(_("Message postponed"));
2425  rc = 1;
2426  goto cleanup;
2427  }
2428  }
2429 
2430 #ifdef USE_NNTP
2431  if (!(flags & SEND_NEWS))
2432 #endif
2433  if ((mutt_addrlist_count_recips(&e_templ->env->to) == 0) &&
2434  (mutt_addrlist_count_recips(&e_templ->env->cc) == 0) &&
2435  (mutt_addrlist_count_recips(&e_templ->env->bcc) == 0))
2436  {
2437  if (flags & SEND_BATCH)
2438  {
2439  puts(_("No recipients specified"));
2440  goto cleanup;
2441  }
2442 
2443  mutt_error(_("No recipients specified"));
2444  goto main_loop;
2445  }
2446 
2447  if (mutt_env_to_intl(e_templ->env, &tag, &err))
2448  {
2449  mutt_error(_("Bad IDN in '%s': '%s'"), tag, err);
2450  FREE(&err);
2451  if (flags & SEND_BATCH)
2452  goto cleanup;
2453  goto main_loop;
2454  }
2455 
2456  if (!e_templ->env->subject && !(flags & SEND_BATCH) &&
2457  (query_quadoption(C_AbortNosubject, _("No subject, abort sending?")) != MUTT_NO))
2458  {
2459  /* if the abort is automatic, print an error message */
2460  if (C_AbortNosubject == MUTT_YES)
2461  mutt_error(_("No subject specified"));
2462  goto main_loop;
2463  }
2464 #ifdef USE_NNTP
2465  if ((flags & SEND_NEWS) && !e_templ->env->subject)
2466  {
2467  mutt_error(_("No subject specified"));
2468  goto main_loop;
2469  }
2470 
2471  if ((flags & SEND_NEWS) && !e_templ->env->newsgroups)
2472  {
2473  mutt_error(_("No newsgroup specified"));
2474  goto main_loop;
2475  }
2476 #endif
2477 
2478  if (!(flags & SEND_BATCH) && (C_AbortNoattach != MUTT_NO) &&
2479  !e_templ->content->next && (e_templ->content->type == TYPE_TEXT) &&
2480  (mutt_str_strcasecmp(e_templ->content->subtype, "plain") == 0) &&
2481  search_attach_keyword(e_templ->content->filename) &&
2483  _("No attachments, cancel sending?")) != MUTT_NO))
2484  {
2485  /* if the abort is automatic, print an error message */
2486  if (C_AbortNoattach == MUTT_YES)
2487  {
2488  mutt_error(_("Message contains text matching "
2489  "\"$abort_noattach_regex\". Not sending."));
2490  }
2491  goto main_loop;
2492  }
2493 
2494  if (e_templ->content->next)
2495  e_templ->content = mutt_make_multipart(e_templ->content);
2496 
2497  /* Ok, we need to do it this way instead of handling all fcc stuff in
2498  * one place in order to avoid going to main_loop with encoded "env"
2499  * in case of error. Ugh. */
2500 
2501  mutt_encode_descriptions(e_templ->content, true);
2502 
2503  /* Make sure that clear_content and free_clear_content are
2504  * properly initialized -- we may visit this particular place in
2505  * the code multiple times, including after a failed call to
2506  * mutt_protect(). */
2507 
2508  clear_content = NULL;
2509  free_clear_content = false;
2510 
2511  if (WithCrypto)
2512  {
2513  if (e_templ->security & (SEC_ENCRYPT | SEC_SIGN | SEC_AUTOCRYPT))
2514  {
2515  /* save the decrypted attachments */
2516  clear_content = e_templ->content;
2517 
2518  if ((crypt_get_keys(e_templ, &pgpkeylist, 0) == -1) ||
2519  (mutt_protect(e_templ, pgpkeylist, false) == -1))
2520  {
2521  e_templ->content = mutt_remove_multipart(e_templ->content);
2522 
2523  FREE(&pgpkeylist);
2524 
2525  decode_descriptions(e_templ->content);
2526  goto main_loop;
2527  }
2528  mutt_encode_descriptions(e_templ->content, false);
2529  }
2530 
2531  /* at this point, e_templ->content is one of the following three things:
2532  * - multipart/signed. In this case, clear_content is a child
2533  * - multipart/encrypted. In this case, clear_content exists independently
2534  * - application/pgp. In this case, clear_content exists independently
2535  * - something else. In this case, it's the same as clear_content
2536  */
2537 
2538  /* This is ugly -- lack of "reporting back" from mutt_protect(). */
2539 
2540  if (clear_content && (e_templ->content != clear_content) &&
2541  (e_templ->content->parts != clear_content))
2542  free_clear_content = true;
2543  }
2544 
2545  if (!OptNoCurses && !(flags & SEND_MAILX))
2546  mutt_message(_("Sending message..."));
2547 
2548  mutt_prepare_envelope(e_templ->env, true);
2549 
2550  if (C_FccBeforeSend)
2551  save_fcc(e_templ, &fcc, clear_content, pgpkeylist, flags, &finalpath);
2552 
2553  i = send_message(e_templ);
2554  if (i < 0)
2555  {
2556  if (!(flags & SEND_BATCH))
2557  {
2558  if (!WithCrypto)
2559  ;
2560  else if ((e_templ->security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) ||
2561  ((e_templ->security & SEC_SIGN) && (e_templ->content->type == TYPE_APPLICATION)))
2562  {
2563  if (e_templ->content != clear_content)
2564  {
2565  mutt_body_free(&e_templ->content); /* destroy PGP data */
2566  e_templ->content = clear_content; /* restore clear text. */
2567  }
2568  }
2569  else if ((e_templ->security & SEC_SIGN) && (e_templ->content->type == TYPE_MULTIPART))
2570  {
2571  mutt_body_free(&e_templ->content->parts->next); /* destroy sig */
2572  e_templ->content = mutt_remove_multipart(e_templ->content);
2573  }
2574 
2575  FREE(&pgpkeylist);
2576  mutt_env_free(&e_templ->content->mime_headers); /* protected headers */
2577  e_templ->content = mutt_remove_multipart(e_templ->content);
2578  decode_descriptions(e_templ->content);
2579  mutt_unprepare_envelope(e_templ->env);
2580  FREE(&finalpath);
2581  goto main_loop;
2582  }
2583  else
2584  {
2585  puts(_("Could not send the message"));
2586  goto cleanup;
2587  }
2588  }
2589 
2590  if (!C_FccBeforeSend)
2591  save_fcc(e_templ, &fcc, clear_content, pgpkeylist, flags, &finalpath);
2592 
2593  if (!OptNoCurses && !(flags & SEND_MAILX))
2594  {
2595  mutt_message((i != 0) ? _("Sending in background") :
2596  (flags & SEND_NEWS) ? _("Article posted") : /* USE_NNTP */
2597  _("Mail sent"));
2598 #ifdef USE_NOTMUCH
2599  if (C_NmRecord)
2600  nm_record_message(ctx ? ctx->mailbox : NULL, finalpath, e_cur);
2601 #endif
2602  mutt_sleep(0);
2603  }
2604 
2605  if (WithCrypto)
2606  FREE(&pgpkeylist);
2607 
2608  if ((WithCrypto != 0) && free_clear_content)
2609  mutt_body_free(&clear_content);
2610 
2611  /* set 'replied' flag only if the user didn't change/remove
2612  * In-Reply-To: and References: headers during edit */
2613  if (flags & SEND_REPLY)
2614  {
2615  if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox)
2616  {
2617  STAILQ_FOREACH(en, el, entries)
2618  {
2619  mutt_set_flag(ctx->mailbox, en->email, MUTT_REPLIED, is_reply(en->email, e_templ));
2620  }
2621  }
2622  }
2623 
2624  rc = 0;
2625 
2626 cleanup:
2627  mutt_buffer_dealloc(&fcc);
2628 
2629  if (flags & SEND_POSTPONED)
2630  {
2631  if (WithCrypto & APPLICATION_PGP)
2632  {
2633  FREE(&C_PgpSignAs);
2634  C_PgpSignAs = pgp_signas;
2635  }
2636  if (WithCrypto & APPLICATION_SMIME)
2637  {
2638  FREE(&C_SmimeSignAs);
2639  C_SmimeSignAs = smime_signas;
2640  }
2641  }
2642 
2643  mutt_file_fclose(&fp_tmp);
2644  if (!(flags & SEND_NO_FREE_HEADER))
2645  email_free(&e_templ);
2646 
2647  FREE(&finalpath);
2648  return rc;
2649 }
#define MUTT_SEND_HOOK
send-hook: when composing a new email
Definition: hook.h:47
void mutt_fix_reply_recipients(struct Envelope *env)
Remove duplicate recipients.
Definition: send.c:900
bool C_Hdrs
Config: Add custom headers to outgoing mail.
Definition: send.c:116
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#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:203
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: sendlib.c:1773
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:69
#define SEND_POSTPONED_FCC
Used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present.
Definition: send.h:97
#define SEND_TO_SENDER
Compose new email to sender.
Definition: send.h:100
The envelope/body of an email.
Definition: email.h:37
#define TAILQ_FIRST(head)
Definition: queue.h:717
#define mutt_perror(...)
Definition: logging.h:85
static int postpone_message(struct Email *e_post, struct Email *e_cur, const char *fcc, SendFlags flags)
Save an Email for another day.
Definition: send.c:1766
static void fix_end_of_file(const char *data)
Ensure a file ends with a linefeed.
Definition: send.c:1470
WHERE bool C_AutocryptReply
Config: Replying to an autocrypt email automatically enables autocrypt in the reply.
Definition: globals.h:204
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: mailbox.h:51
unsigned char C_AbortNoattach
Config: Abort sending the email if attachments are missing.
Definition: send.c:91
static bool search_attach_keyword(char *filename)
Search an email for &#39;attachment&#39; keywords.
Definition: send.c:1557
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:3340
#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:1593
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
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
#define SEND_DRAFT_FILE
Used by the -H flag.
Definition: send.h:99
#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:317
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:1020
#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:379
#define SEND_FORWARD
Forward email.
Definition: send.h:91
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:108
struct Body * content
List of MIME parts.
Definition: email.h:90
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
int mutt_edit_attachment(struct Body *a)
Edit an attachment.
Definition: mutt_attach.c:255
String manipulation buffer.
Definition: buffer.h:33
#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:94
WHERE bool C_PgpAutoinline
Config: Use old-style inline PGP messages (not recommended)
Definition: globals.h:286
struct Body * next
next attachment in the list
Definition: body.h:53
An email address.
Definition: address.h:34
WHERE unsigned char C_Copy
Config: Save outgoing emails to $record.
Definition: globals.h:184
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:46
#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:100
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_env_to_intl(struct Envelope *env, const char **tag, char **err)
Convert an Envelope&#39;s Address fields to Punycode format.
Definition: envelope.c:309
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define SEND_POSTPONED
Recall a postponed email.
Definition: send.h:92
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:704
bool C_CryptReplysign
Config: Sign replies to signed messages.
Definition: send.c:103
Messages that have been replied to.
Definition: mutt.h:99
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:3007
unsigned int disposition
content-disposition
Definition: body.h:67
int nm_record_message(struct Mailbox *m, char *path, struct Email *e)
Add a message to the Notmuch database.
WHERE bool C_SmimeIsDefault
Config: Use SMIME rather than PGP by default.
Definition: globals.h:282
bool C_CryptAutosmime
Config: Allow automatic SMIME functions.
Definition: send.c:101
#define SEND_MAILX
Send email in Mailx compatibility mode.
Definition: send.h:94
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1546
WHERE bool C_EditHeaders
Config: Let the user edit the email headers whilst editing an email.
Definition: globals.h:215
struct Mailbox * mailbox
Definition: context.h:50
unsigned char C_Recall
Config: Recall postponed mesaages when asked to compose a message.
Definition: send.c:126
struct Body * mutt_body_new(void)
Create a new Body.
Definition: body.c:43
unsigned char C_AbortNosubject
Config: Abort creating the email if subject is missing.
Definition: send.c:93
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
void mutt_update_encoding(struct Body *a)
Update the encoding type.
Definition: sendlib.c:1486
static void process_user_recips(struct Envelope *env)
Process the user headers.
Definition: send.c:352
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
struct Envelope * env
Envelope information.
Definition: email.h:89
static void decode_descriptions(struct Body *b)
rfc2047 decode them in case of an error
Definition: send.c:1453
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:206
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:90
static bool is_reply(struct Email *reply, struct Email *orig)
Is one email a reply to another?
Definition: send.c:1539
void * mdata
Driver specific data.
Definition: mailbox.h:147
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:42
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
Definition: sendlib.c:1747
#define SEND_KEY
Mail a PGP public key.
Definition: send.h:95
char * subtype
content-type subtype
Definition: body.h:37
#define mutt_b2s(buf)
Definition: buffer.h:41
bool C_FastReply
Config: Don&#39;t prompt for the recipients and subject when replying/forwarding.
Definition: send.c:106
#define SEND_RESEND
Reply using the current email as a template.
Definition: send.h:96
void mutt_unprepare_envelope(struct Envelope *env)
Undo the encodings of mutt_prepare_envelope()
Definition: sendlib.c:3046
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
struct Address * mutt_default_from(void)
Get a default &#39;from&#39; Address.
Definition: send.c:1322
WHERE bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient&#39;s key is available.
Definition: globals.h:278
bool C_ReverseName
Config: Set the &#39;From&#39; from the address the email was sent to.
Definition: send.c:130
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
void mutt_encode_descriptions(struct Body *b, bool recurse)
rfc2047 encode the content-descriptions
Definition: send.c:1436
void mutt_select_fcc(struct Buffer *path, struct Email *e)
Select the FCC path for an email.
Definition: hook.c:694
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:1090
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
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 SEND_NEWS
Reply to a news article.
Definition: send.h:102
#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:1273
#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:39
bool C_PgpReplyinline
Config: Reply using old-style inline PGP messages (not recommended)
Definition: send.c:122
#define SEND_REPLY
Reply to sender.
Definition: send.h:88
NNTP-specific Mailbox data -.
Definition: nntp.h:138
bool C_SigOnTop
Config: Insert the signature before the quoted text.
Definition: send.c:134
#define SEND_NO_FREE_HEADER
Used by the -E flag.
Definition: send.h:98
unsigned char C_ForwardEdit
Config: Automatically start the editor when forwarding a message.
Definition: send.c:113
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:102
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:160
char * personal
Real name of address.
Definition: address.h:36
int mutt_num_postponed(struct Mailbox *m, bool force)
Return the number of postponed messages.
Definition: postpone.c:87
WHERE bool C_TextFlowed
Config: Generate &#39;format=flowed&#39; messages.
Definition: globals.h:266
void mutt_parse_content_type(const char *s, struct Body *ct)
Parse a content type.
Definition: parse.c:454
void mutt_env_to_local(struct Envelope *env)
Convert an Envelope&#39;s Address fields to local format.
Definition: envelope.c:271
void mutt_edit_headers(const char *editor, const char *body, struct Email *e, struct Buffer *fcc)
Let the user edit the message header and body.
Definition: mutt_header.c:167
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:252
char * subject
Email&#39;s subject.
Definition: envelope.h:66
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
Log at debug level 1.
Definition: logging.h:56
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 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:270
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
struct Email * email
Email in the list.
Definition: email.h:116
#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:425
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 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:54
void mutt_rfc3676_space_stuff(struct Email *e)
Perform RFC3676 space stuffing on an Email.
Definition: rfc3676.c:468
static int edit_envelope(struct Envelope *en, SendFlags flags)
Edit Envelope fields.
Definition: send.c:243
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
WHERE char * C_Editor
Config: External command to use as an email editor.
Definition: globals.h:111
bool C_UseFrom
Config: Set the &#39;From&#39; header for outgoing mail.
Definition: send.c:135
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:961
#define MUTT_REPLY_HOOK
reply-hook: when replying to an email
Definition: hook.h:55
#define FREE(x)
Definition: memory.h:40
#define MUTT_COMPOSE_NOFREEHEADER
Definition: compose.h:36
static int save_fcc(struct Email *e, struct Buffer *fcc, struct Body *clear_content, char *pgpkeylist, SendFlags flags, char **finalpath)
Save an Email to a &#39;sent mail&#39; folder.
Definition: send.c:1598
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
List of Emails.
Definition: email.h:114
struct Email * email_new(void)
Create a new Email.
Definition: email.c:68
WHERE char * C_Realname
Config: Real name of the user.
Definition: globals.h:140
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:573
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
#define TAILQ_EMPTY(head)
Definition: queue.h:715
WHERE bool OptNewsSend
(pseudo) used to change behavior when posting
Definition: options.h:44
Log at debug level 5.
Definition: logging.h:60
WHERE char * C_PgpSignAs
Config: Use this alternative key for signing messages.
Definition: globals.h:165
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:585
WHERE char * C_SmimeSignAs
Config: Use this alternative key for signing messages.
Definition: globals.h:169
static void append_signature(FILE *fp)
Append a signature to an email.
Definition: send.c:141
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:41
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
char * C_ContentType
Config: Default "Content-Type" for newly composed messages.
Definition: send.c:97
Content is inline.
Definition: mime.h:62
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
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
void mutt_edit_file(const char *editor, const char *file)
Let the user edit a file.
Definition: curs_lib.c:351
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:1350
int mutt_get_postponed(struct Context *ctx, struct Email *hdr, struct Email **cur, struct Buffer *fcc)
Recall a postponed message.
Definition: postpone.c:295
Type: &#39;application/*&#39;.
Definition: mime.h:33
QuadOption
Possible values for a quad-option.
Definition: quad.h:35
int mutt_compose_menu(struct Email *e, struct Buffer *fcc, struct Email *e_cur, int flags)
Allow the user to edit the message envelope.
Definition: compose.c:1096
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
Definition: parameter.c:110
#define SEND_BATCH
Send email in batch mode (without user interaction)
Definition: send.h:93
bool C_CryptReplysignencrypted
Config: Sign replies to encrypted messages.
Definition: send.c:104
bool C_NmRecord
Config: (notmuch) If the &#39;record&#39; mailbox (sent mail) should be indexed.
Definition: send.c:121
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_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:265
bool C_CryptAutopgp
Config: Allow automatic PGP functions.
Definition: send.c:99
bool C_CryptAutoencrypt
Config: Automatically PGP encrypt all outgoing mail.
Definition: send.c:98
bool C_ReplyWithXorig
Config: Create &#39;From&#39; header from &#39;X-Original-To&#39; header.
Definition: send.c:129
+ Here is the caller graph for this function:

Variable Documentation

◆ C_AbortNoattach

unsigned char C_AbortNoattach

Config: Abort sending the email if attachments are missing.

Definition at line 91 of file send.c.

◆ C_AbortNoattachRegex

struct Regex* C_AbortNoattachRegex

Config: Regex to match text indicating attachments are expected.

Definition at line 92 of file send.c.

◆ C_AbortNosubject

unsigned char C_AbortNosubject

Config: Abort creating the email if subject is missing.

Definition at line 93 of file send.c.

◆ C_AbortUnmodified

unsigned char C_AbortUnmodified

Config: Abort the sending if the message hasn't been edited.

Definition at line 94 of file send.c.

◆ C_AskFollowUp

bool C_AskFollowUp

Config: (nntp) Ask the user for follow-up groups before editing.

Definition at line 95 of file send.c.

◆ C_AskXCommentTo

bool C_AskXCommentTo

Config: (nntp) Ask the user for the 'X-Comment-To' field before editing.

Definition at line 96 of file send.c.

◆ C_ContentType

char* C_ContentType

Config: Default "Content-Type" for newly composed messages.

Definition at line 97 of file send.c.

◆ C_CryptAutoencrypt

bool C_CryptAutoencrypt

Config: Automatically PGP encrypt all outgoing mail.

Definition at line 98 of file send.c.

◆ C_CryptAutopgp

bool C_CryptAutopgp

Config: Allow automatic PGP functions.

Definition at line 99 of file send.c.

◆ C_CryptAutosign

bool C_CryptAutosign

Config: Automatically PGP sign all outgoing mail.

Definition at line 100 of file send.c.

◆ C_CryptAutosmime

bool C_CryptAutosmime

Config: Allow automatic SMIME functions.

Definition at line 101 of file send.c.

◆ C_CryptReplyencrypt

bool C_CryptReplyencrypt

Config: Encrypt replies to encrypted messages.

Definition at line 102 of file send.c.

◆ C_CryptReplysign

bool C_CryptReplysign

Config: Sign replies to signed messages.

Definition at line 103 of file send.c.

◆ C_CryptReplysignencrypted

bool C_CryptReplysignencrypted

Config: Sign replies to encrypted messages.

Definition at line 104 of file send.c.

◆ C_EmptySubject

char* C_EmptySubject

Config: Subject to use when replying to an email with none.

Definition at line 105 of file send.c.

◆ C_FastReply

bool C_FastReply

Config: Don't prompt for the recipients and subject when replying/forwarding.

Definition at line 106 of file send.c.

◆ C_FccAttach

unsigned char C_FccAttach

Config: Save send message with all their attachments.

Definition at line 107 of file send.c.

◆ C_FccBeforeSend

bool C_FccBeforeSend

Config: Save FCCs before sending the message.

Definition at line 108 of file send.c.

◆ C_FccClear

bool C_FccClear

Config: Save sent messages unencrypted and unsigned.

Definition at line 109 of file send.c.

◆ C_FollowupTo

bool C_FollowupTo

Config: Add the 'Mail-Followup-To' header is generated when sending mail.

Definition at line 110 of file send.c.

◆ C_ForwardAttributionIntro

char* C_ForwardAttributionIntro

Config: Prefix message for forwarded messages.

Definition at line 111 of file send.c.

◆ C_ForwardAttributionTrailer

char* C_ForwardAttributionTrailer

Config: Suffix message for forwarded messages.

Definition at line 112 of file send.c.

◆ C_ForwardEdit

unsigned char C_ForwardEdit

Config: Automatically start the editor when forwarding a message.

Definition at line 113 of file send.c.

◆ C_ForwardFormat

char* C_ForwardFormat

Config: printf-like format string to control the subject when forwarding a message.

Definition at line 114 of file send.c.

◆ C_ForwardReferences

bool C_ForwardReferences

Config: Set the 'In-Reply-To' and 'References' headers when forwarding a message.

Definition at line 115 of file send.c.

◆ C_Hdrs

bool C_Hdrs

Config: Add custom headers to outgoing mail.

Definition at line 116 of file send.c.

◆ C_HonorFollowupTo

unsigned char C_HonorFollowupTo

Config: Honour the 'Mail-Followup-To' header when group replying.

Definition at line 117 of file send.c.

◆ C_IgnoreListReplyTo

bool C_IgnoreListReplyTo

Config: Ignore the 'Reply-To' header when using <reply> on a mailing list.

Definition at line 118 of file send.c.

◆ C_Include

unsigned char C_Include

Config: Include a copy of the email that's being replied to.

Definition at line 119 of file send.c.

◆ C_Metoo

bool C_Metoo

Config: Remove the user's address from the list of recipients.

Definition at line 120 of file send.c.

◆ C_NmRecord

bool C_NmRecord

Config: (notmuch) If the 'record' mailbox (sent mail) should be indexed.

Definition at line 121 of file send.c.

◆ C_PgpReplyinline

bool C_PgpReplyinline

Config: Reply using old-style inline PGP messages (not recommended)

Definition at line 122 of file send.c.

◆ C_PostIndentString

char* C_PostIndentString

Config: Suffix message to add after reply text.

Definition at line 123 of file send.c.

◆ C_PostponeEncrypt

bool C_PostponeEncrypt

Config: Self-encrypt postponed messages.

Definition at line 124 of file send.c.

◆ C_PostponeEncryptAs

char* C_PostponeEncryptAs

Config: Fallback encryption key for postponed messages.

Definition at line 125 of file send.c.

◆ C_Recall

unsigned char C_Recall

Config: Recall postponed mesaages when asked to compose a message.

Definition at line 126 of file send.c.

◆ C_ReplySelf

bool C_ReplySelf

Config: Really reply to yourself, when replying to your own email.

Definition at line 127 of file send.c.

◆ C_ReplyTo

unsigned char C_ReplyTo

Config: Address to use as a 'Reply-To' header.

Definition at line 128 of file send.c.

◆ C_ReplyWithXorig

bool C_ReplyWithXorig

Config: Create 'From' header from 'X-Original-To' header.

Definition at line 129 of file send.c.

◆ C_ReverseName

bool C_ReverseName

Config: Set the 'From' from the address the email was sent to.

Definition at line 130 of file send.c.

◆ C_ReverseRealname

bool C_ReverseRealname

Config: Set the 'From' from the full 'To' address the email was sent to.

Definition at line 131 of file send.c.

◆ C_SigDashes

bool C_SigDashes

Config: Insert '– ' before the signature.

Definition at line 132 of file send.c.

◆ C_Signature

char* C_Signature

Config: File containing a signature to append to all mail.

Definition at line 133 of file send.c.

◆ C_SigOnTop

bool C_SigOnTop

Config: Insert the signature before the quoted text.

Definition at line 134 of file send.c.

◆ C_UseFrom

bool C_UseFrom

Config: Set the 'From' header for outgoing mail.

Definition at line 135 of file send.c.