break;
case OP_COMPOSE_TO_SENDER:
- if (Context)
- {
- mutt_compose_to_sender(tag ? NULL : CURHDR);
- menu->redraw = REDRAW_FULL;
- }
+ CHECK_ATTACH;
+ CHECK_MSGCOUNT;
+ CHECK_VISIBLE;
+ ci_send_message (SEND_TO_SENDER, NULL, NULL, Context, tag ? NULL : CURHDR);
+ menu->redraw = REDRAW_FULL;
break;
/* --------------------------------------------------------------------
{ "bounce-message", OP_BOUNCE_MESSAGE, "b" },
{ "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
{ "collapse-parts", OP_ATTACH_COLLAPSE, "v" },
+ { "compose-to-sender", OP_COMPOSE_TO_SENDER, NULL },
{ "delete-entry", OP_DELETE, "d" },
{ "display-toggle-weed", OP_DISPLAY_HEADERS, "h" },
{ "edit-type", OP_EDIT_TYPE, "\005" },
_fmt(OP_COMPOSE_TOGGLE_DISPOSITION, N_("toggle disposition between inline/attachment")) \
_fmt(OP_COMPOSE_TOGGLE_RECODE, N_("toggle recoding of this attachment")) \
_fmt(OP_COMPOSE_TOGGLE_UNLINK, N_("toggle whether to delete file after sending it")) \
- _fmt(OP_COMPOSE_TO_SENDER, N_("compose a new message to the sender")) \
+ _fmt(OP_COMPOSE_TO_SENDER, N_("compose new message to the current message sender")) \
_fmt(OP_COMPOSE_UPDATE_ENCODING, N_("update an attachment's encoding info")) \
_fmt(OP_COMPOSE_WRITE_MESSAGE, N_("write the message to a folder")) \
_fmt(OP_COPY_MESSAGE, N_("copy a message to a file/mailbox")) \
break;
case OP_COMPOSE_TO_SENDER:
- mutt_compose_to_sender(extra->hdr);
+ CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
+ CHECK_ATTACH;
+ if (IsMsgAttach (extra))
+ mutt_attach_mail_sender (extra->fp, extra->hdr, extra->actx, extra->bdy);
+ else
+ ci_send_message (SEND_TO_SENDER, NULL, NULL, extra->ctx, extra->hdr);
pager_menu->redraw = REDRAW_FULL;
break;
menu->redraw = REDRAW_FULL;
break;
+ case OP_COMPOSE_TO_SENDER:
+ CHECK_ATTACH;
+ mutt_attach_mail_sender (CURATTACH->fp, hdr, actx,
+ menu->tagprefix ? NULL : CURATTACH->content);
+ menu->redraw = REDRAW_FULL;
+ break;
+
case OP_EDIT_TYPE:
recvattach_edit_content_type(actx, menu, hdr);
menu->redraw |= REDRAW_INDEX;
mutt_set_flag(Context, hdr, MUTT_REPLIED, 1);
}
}
+
+void mutt_attach_mail_sender(FILE *fp, struct Header *hdr,
+ struct AttachCtx *actx, struct Body *cur)
+{
+ if (!check_all_msg(actx, cur, 0))
+ {
+ mutt_error(_("You may only compose to sender with message/rfc822 parts."));
+ return;
+ }
+
+ struct Header *tmphdr = mutt_header_new();
+ tmphdr->env = mutt_env_new();
+
+ if (cur)
+ {
+ if (mutt_fetch_recips(tmphdr->env, cur->hdr->env, SEND_TO_SENDER) == -1)
+ return;
+ }
+ else
+ {
+ for (int i = 0; i < actx->idxlen; i++)
+ {
+ if (actx->idx[i]->content->tagged &&
+ mutt_fetch_recips(tmphdr->env, actx->idx[i]->content->hdr->env, SEND_TO_SENDER) == -1)
+ return;
+ }
+ }
+ ci_send_message(0, tmphdr, NULL, NULL, NULL);
+}
void mutt_attach_resend(FILE *fp, struct AttachCtx *actx, struct Body *cur);
void mutt_attach_forward(FILE *fp, struct Header *hdr, struct AttachCtx *actx, struct Body *cur, int flags);
void mutt_attach_reply(FILE *fp, struct Header *hdr, struct AttachCtx *actx, struct Body *cur, int flags);
+void mutt_attach_mail_sender(FILE *fp, struct Header *hdr, struct AttachCtx *actx, struct Body *cur);
#endif /* _MUTT_RECVCMD_H */
return -1; /* abort */
}
}
+ else if (flags & SEND_TO_SENDER)
+ {
+ mutt_addr_append(&out->to, in->from, 0);
+ }
else
{
if (default_to(&out->to, in, flags & SEND_GROUP_REPLY, hmfupto) == MUTT_ABORT)
if (!curenv)
return -1;
- if (flags & SEND_REPLY)
+ if (flags & (SEND_REPLY|SEND_TO_SENDER))
{
#ifdef USE_NNTP
if ((flags & SEND_NEWS))
return -1;
}
- mutt_make_misc_reply_headers(env, curenv);
- make_reference_headers(tag ? NULL : curenv, env, ctx);
+ if (flags & SEND_REPLY)
+ {
+ mutt_make_misc_reply_headers(env, curenv);
+ make_reference_headers (tag ? NULL : curenv, env, ctx);
+ }
}
else if (flags & SEND_FORWARD)
{
mutt_file_fclose(&fp);
}
-/**
- * mutt_compose_to_sender - Compose an email to the sender
- * @param hdr Header of original email
- * @retval 0 Message was successfully sent
- * @retval -1 Message was aborted or an error occurred
- * @retval 1 Message was postponed
- */
-int mutt_compose_to_sender(struct Header *hdr)
-{
- struct Header *msg = mutt_header_new();
-
- msg->env = mutt_env_new();
- if (!hdr)
- {
- for (int i = 0; i < Context->msgcount; i++)
- {
- if (message_is_tagged(Context, i))
- mutt_addr_append(&msg->env->to, Context->hdrs[i]->env->from, false);
- }
- }
- else
- msg->env->to = mutt_addr_copy_list(hdr->env->from, false);
-
- return ci_send_message(0, msg, NULL, NULL, NULL);
-}
-
/**
* mutt_resend_message - Resend an email
* @param fp File containing email
if (!(flags & (SEND_POSTPONED | SEND_RESEND)) && !((flags & SEND_DRAFT_FILE) && ResumeDraftFiles))
{
- if ((flags & (SEND_REPLY | SEND_FORWARD)) && ctx &&
+ if ((flags & (SEND_REPLY | SEND_FORWARD | SEND_TO_SENDER)) && ctx &&
envelope_defaults(msg->env, ctx, cur, flags) == -1)
{
goto cleanup;
#define SEND_POSTPONED_FCC (1 << 9) /**< used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */
#define SEND_NO_FREE_HEADER (1 << 10) /**< Used by the -E flag */
#define SEND_DRAFT_FILE (1 << 11) /**< Used by the -H flag */
-#define SEND_NEWS (1 << 12)
+#define SEND_TO_SENDER (1 << 12)
+#define SEND_NEWS (1 << 13)
int ci_send_message(int flags, struct Header *msg, char *tempfile, struct Context *ctx, struct Header *cur);
void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv);
-int mutt_compose_to_sender(struct Header *hdr);
struct Address *mutt_default_from(void);
void mutt_encode_descriptions(struct Body *b, bool recurse);
int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags);