91static int send_msg(
const char *path,
struct SendmailArgArray *args,
92 const char *msg,
char **tempfile,
int wait_time)
101 sigaddset(&set, SIGTSTP);
102 sigprocmask(SIG_BLOCK, &set, NULL);
104 if ((wait_time >= 0) && tempfile)
115 struct sigaction act = { 0 };
116 struct sigaction oldalrm = { 0 };
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)
174 execvp(path, (
char **) args->entries);
193 act.sa_flags = SA_INTERRUPT;
197 sigemptyset(&act.sa_mask);
198 sigaction(SIGALRM, &act, &oldalrm);
201 else if (wait_time < 0)
206 if (waitpid(pid, &st, 0) > 0)
208 st = WIFEXITED(st) ? WEXITSTATUS(st) :
S_ERR;
209 if (wait_time && (st == (0xff &
EX_OK)) && tempfile && *tempfile)
218 if ((wait_time > 0) && tempfile && *tempfile)
229 sigaction(SIGALRM, &oldalrm, NULL);
232 if ((kill(ppid, 0) == -1) && (errno == ESRCH) && tempfile && *tempfile)
242 sigprocmask(SIG_UNBLOCK, &set, NULL);
244 if ((pid != -1) && (waitpid(pid, &st, 0) > 0))
245 st = WIFEXITED(st) ? WEXITSTATUS(st) :
S_ERR;
273static void add_args(
struct SendmailArgArray *args,
struct AddressList *al)
301 struct AddressList *to,
struct AddressList *cc,
302 struct AddressList *bcc,
const char *msg,
305 char *ps = NULL, *path = NULL, *s = NULL, *childout = NULL;
335 mutt_error(
_(
"$sendmail must be set in order to send mail"));
341 while ((ps = strtok(ps,
" ")))
352 ps = strrchr(ps,
'/');
370 while ((ps = strtok(ps,
" ")))
377 const bool c_use_8bit_mime =
cs_subset_bool(sub,
"use_8bit_mime");
378 if (eightbit && c_use_8bit_mime)
381 const bool c_use_envelope_from =
cs_subset_bool(sub,
"use_envelope_from");
382 if (c_use_envelope_from)
385 if (c_envelope_from_address)
411 const char **e = NULL;
435 if (i != (
EX_OK & 0xff))
443 struct stat st = { 0 };
445 if ((stat(childout, &st) == 0) && (st.st_size > 0))
452 pview.
banner =
_(
"Output of the delivery process");
472 if (i == (
EX_OK & 0xff))
const struct Address * cs_subset_address(const struct ConfigSubset *sub, const char *name)
Get an Address config item by name.
#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_HEAD(name, type)
Define a named struct for arrays of elements of a certain type.
#define ARRAY_FREE(head)
Release all memory.
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
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.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void mutt_need_hard_redraw(void)
Force a hard refresh.
int expando_filter(const struct Expando *exp, const struct ExpandoRenderCallback *erc, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando and run the result through a filter.
const struct ExpandoRenderCallback NntpRenderCallbacks[]
Callbacks for Newsrc Expandos.
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.
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.
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)
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
static void alarm_handler(int sig)
Async notification of an alarm signal.
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.
static void add_args_one(struct SendmailArgArray *args, const struct Address *addr)
Add an Address to a dynamic array.
static volatile sig_atomic_t SigAlrm
true after SIGALRM is received
static void add_args(struct SendmailArgArray *args, struct AddressList *al)
Add a list of Addresses to a dynamic array.
static int send_msg(const char *path, struct SendmailArgArray *args, const char *msg, char **tempfile, int wait_time)
Invoke sendmail in a subshell.
Send email using sendmail.
void mutt_sig_reset_child_signals(void)
Reset ignored signals back to the default.
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.
size_t dsize
Length of data.
A set of inherited config items.