92static int send_msg(
const char *path,
struct SendmailArgs *args,
93 const char *msg,
char **tempfile,
int wait_time)
102 sigaddset(&set, SIGTSTP);
103 sigprocmask(SIG_BLOCK, &set, NULL);
105 if ((wait_time >= 0) && tempfile)
116 struct sigaction act, oldalrm;
119 pid_t ppid = getppid();
128 for (
int fd = tempfile ? 1 : 3; fd < OPEN_MAX; fd++)
130#elif defined(_POSIX_OPEN_MAX)
131 for (
int fd = tempfile ? 1 : 3; fd < _POSIX_OPEN_MAX; fd++)
146 if (open(msg, O_RDONLY, 0) < 0)
153 if ((wait_time >= 0) && tempfile && *tempfile)
156 if (open(*tempfile, O_WRONLY | O_APPEND | O_CREAT | O_EXCL, 0600) < 0)
164 if (open(
"/dev/null", O_WRONLY | O_APPEND) < 0)
166 if (open(
"/dev/null", O_RDWR | O_APPEND) < 0)
172 execvp(path, (
char **) args->entries);
191 act.sa_flags = SA_INTERRUPT;
195 sigemptyset(&act.sa_mask);
196 sigaction(SIGALRM, &act, &oldalrm);
199 else if (wait_time < 0)
204 if (waitpid(pid, &st, 0) > 0)
206 st = WIFEXITED(st) ? WEXITSTATUS(st) :
S_ERR;
207 if (wait_time && (st == (0xff &
EX_OK)) && tempfile && *tempfile)
216 if ((wait_time > 0) && tempfile && *tempfile)
227 sigaction(SIGALRM, &oldalrm, NULL);
230 if ((kill(ppid, 0) == -1) && (errno == ESRCH) && tempfile && *tempfile)
240 sigprocmask(SIG_UNBLOCK, &set, NULL);
242 if ((pid != -1) && (waitpid(pid, &st, 0) > 0))
243 st = WIFEXITED(st) ? WEXITSTATUS(st) :
S_ERR;
271static void add_args(
struct SendmailArgs *args,
struct AddressList *al)
299 struct AddressList *to,
struct AddressList *cc,
300 struct AddressList *bcc,
const char *msg,
303 char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
311 char cmd[1024] = { 0 };
335 mutt_error(
_(
"$sendmail must be set in order to send mail"));
341 while ((ps = strtok(ps,
" ")))
352 ps = strrchr(ps,
'/');
372 while ((ps = strtok(ps,
" ")))
379 const bool c_use_8bit_mime =
cs_subset_bool(sub,
"use_8bit_mime");
380 if (eightbit && c_use_8bit_mime)
383 const bool c_use_envelope_from =
cs_subset_bool(sub,
"use_envelope_from");
384 if (c_use_envelope_from)
387 if (c_envelope_from_address)
413 const char **e = NULL;
439 if (i != (
EX_OK & 0xff))
447 struct stat st = { 0 };
449 if ((stat(childout, &st) == 0) && (st.st_size > 0))
456 pview.
banner =
_(
"Output of the delivery process");
476 if (i == (
EX_OK & 0xff))
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_FREE(head)
Release all memory.
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
const struct Address * cs_subset_address(const struct ConfigSubset *sub, const char *name)
Get an Address config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
void mutt_need_hard_redraw(void)
Force a hard refresh.
bool OptNoCurses
(pseudo) when sending in batch mode
bool OptNewsSend
(pseudo) used to change behavior when posting
char ** EnvList
Private copy of the environment variables.
const char * nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Expand the newsrc filename - Implements format_t -.
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
Convenience wrapper for the gui headers.
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
const char * mutt_str_sysexit(int err_num)
Return a string matching an error code.
Some miscellaneous functions.
Usenet network mailbox type; talk to an NNTP server.
int nntp_post(struct Mailbox *m, const char *msg)
Post article.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_FIRST(head)
#define TAILQ_NEXT(elm, field)
#define TAILQ_EMPTY(head)
static void alarm_handler(int sig)
Async notification of an alarm signal.
static void add_args_one(struct SendmailArgs *args, const struct Address *addr)
Add an Address to a dynamic array.
int mutt_invoke_sendmail(struct Mailbox *m, struct AddressList *from, struct AddressList *to, struct AddressList *cc, struct AddressList *bcc, const char *msg, bool eightbit, struct ConfigSubset *sub)
Run sendmail.
ARRAY_HEAD(SendmailArgs, const char *)
static int send_msg(const char *path, struct SendmailArgs *args, const char *msg, char **tempfile, int wait_time)
Invoke sendmail in a subshell.
static void add_args(struct SendmailArgs *args, struct AddressList *al)
Add a list of Addresses to a dynamic array.
static SIG_ATOMIC_VOLATILE_T SigAlrm
true after SIGALRM is received
void mutt_sig_block_system(void)
Block signals before calling exec()
void mutt_sig_unblock_system(bool restore)
Restore previously blocked signals.
struct Buffer * mailbox
Mailbox and host address.
String manipulation buffer.
A set of inherited config items.