NeoMutt  2023-03-22-27-g3cb248
Teaching an old dog new tricks
Go to the documentation of this file.
30#include "config.h"
31#include <stdbool.h>
32#include <stdio.h>
33#include <string.h>
34#include <unistd.h>
35#include "mutt/lib.h"
36#include "address/lib.h"
37#include "config/lib.h"
38#include "email/lib.h"
39#include "core/lib.h"
40#include "gui/lib.h"
41#include "send/lib.h"
42#include "globals.h" // IWYU pragma: keep
43#include "protos.h"
53 bool need_hostname = false;
55 if (!TAILQ_EMPTY(&e->env->cc) || !TAILQ_EMPTY(&e->env->bcc))
56 {
57 mutt_error(_("Mixmaster doesn't accept Cc or Bcc headers"));
58 return -1;
59 }
61 /* When using mixmaster, we MUST qualify any addresses since
62 * the message will be delivered through remote systems.
63 *
64 * use_domain won't be respected at this point, hidden_host will.
65 */
67 struct Address *a = NULL;
68 TAILQ_FOREACH(a, &e->env->to, entries)
69 {
70 if (!a->group && !strchr(a->mailbox, '@'))
71 {
72 need_hostname = true;
73 break;
74 }
75 }
77 if (need_hostname)
78 {
79 const char *fqdn = mutt_fqdn(true, NeoMutt->sub);
80 if (!fqdn)
81 {
82 mutt_error(_("Please set the hostname variable to a proper value when using mixmaster"));
83 return -1;
84 }
86 /* Cc and Bcc are empty at this point. */
87 mutt_addrlist_qualify(&e->env->to, fqdn);
90 }
92 return 0;
102int mix_send_message(struct ListHead *chain, const char *tempfile)
104 int i = 0;
105 struct Buffer *cmd = mutt_buffer_pool_get();
106 struct Buffer *cd_quoted = mutt_buffer_pool_get();
108 const char *const c_mixmaster = cs_subset_string(NeoMutt->sub, "mixmaster");
109 mutt_buffer_printf(cmd, "cat %s | %s -m ", tempfile, c_mixmaster);
111 struct ListNode *np = NULL;
112 STAILQ_FOREACH(np, chain, entries)
113 {
114 mutt_buffer_addstr(cmd, (i != 0) ? "," : " -l ");
115 mutt_buffer_quote_filename(cd_quoted, (char *) np->data, true);
116 mutt_buffer_addstr(cmd, mutt_buffer_string(cd_quoted));
117 i = 1;
118 }
120 mutt_endwin();
122 i = mutt_system(cmd->data);
123 if (i != 0)
124 {
125 fprintf(stderr, _("Error sending message, child exited %d\n"), i);
126 if (!OptNoCurses)
127 {
129 mutt_error(_("Error sending message"));
130 }
131 }
134 mutt_buffer_pool_release(&cd_quoted);
135 unlink(tempfile);
136 return i;
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:656
Email Address Handling.
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:233
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:168
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:78
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:386
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:353
Structs that make up an email.
void mutt_buffer_quote_filename(struct Buffer *buf, const char *filename, bool add_outer)
Quote a filename to survive the shell's quoting rules.
Definition: file.c:911
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: globals.c:81
#define mutt_error(...)
Definition: logging.h:87
Convenience wrapper for the gui headers.
int mix_send_message(struct ListHead *chain, const char *tempfile)
Send an email via Mixmaster.
Definition: mixmaster.c:102
int mix_check_message(struct Email *e)
Safety-check the message before passing it to mixmaster.
Definition: mixmaster.c:51
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
Prototypes for many functions.
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define TAILQ_EMPTY(head)
Definition: queue.h:721
Convenience wrapper for the send headers.
const char * mutt_fqdn(bool may_hide_host, const struct ConfigSubset *sub)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:700
An email address.
Definition: address.h:36
bool group
Group mailbox?
Definition: address.h:39
char * mailbox
Mailbox and host address.
Definition: address.h:38
String manipulation buffer.
Definition: buffer.h:34
char * data
Pointer to data.
Definition: buffer.h:35
The envelope/body of an email.
Definition: email.h:37
struct Envelope * env
Envelope information.
Definition: email.h:66
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
struct AddressList reply_to
Email's 'reply-to'.
Definition: envelope.h:64
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
Definition: envelope.h:65
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:61
struct AddressList bcc
Email's 'Bcc' list.
Definition: envelope.h:62
A List node for strings.
Definition: list.h:35
char * data
Definition: list.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39