Write email to FCC mailbox.
1032{
1034 struct Buffer *tempfile = NULL;
1035 FILE *fp_tmp = NULL;
1036 int rc = -1;
1037 bool need_mailbox_cleanup = false;
1038 struct stat st = { 0 };
1040
1041 if (post)
1043
1044#ifdef RECORD_FOLDER_HOOK
1046#endif
1048 bool old_append = m_fcc->
append;
1050 {
1052 goto done;
1053 }
1054
1055
1056
1058 {
1062 if (!fp_tmp)
1063 {
1066 goto done;
1067 }
1068
1069 need_mailbox_cleanup = true;
1070 stat(path, &st);
1071 }
1072
1075 if (post)
1078 if (!msg)
1079 {
1082 goto done;
1083 }
1084
1085 const bool c_crypt_protected_headers_read =
cs_subset_bool(
sub,
"crypt_protected_headers_read");
1086
1087
1088
1091 c_crypt_protected_headers_read &&
1094
1095
1096
1097
1098
1099
1100 if (post && msgid)
1101 fprintf(msg->
fp,
"X-Mutt-References: %s\n", msgid);
1102
1103
1104
1105 if (post && fcc)
1106 fprintf(msg->
fp,
"X-Mutt-Fcc: %s\n", fcc);
1107
1109 fprintf(msg->
fp,
"Status: RO\n");
1110
1111
1113 {
1114 fputs(
"X-Mutt-PGP: ", msg->
fp);
1116 fputc(
'E', msg->
fp);
1118 fputc(
'O', msg->
fp);
1120 {
1121 fputc(
'S', msg->
fp);
1122
1124 if (c_pgp_sign_as)
1125 fprintf(msg->
fp,
"<%s>", c_pgp_sign_as);
1126 }
1128 fputc(
'I', msg->
fp);
1129#ifdef USE_AUTOCRYPT
1131 fputc(
'A', msg->
fp);
1133 fputc(
'Z', msg->
fp);
1134#endif
1135 fputc(
'\n', msg->
fp);
1136 }
1137
1138
1140 {
1141 fputs(
"X-Mutt-SMIME: ", msg->
fp);
1143 {
1144 fputc(
'E', msg->
fp);
1145
1147 if (c_smime_encrypt_with)
1148 fprintf(msg->
fp,
"C<%s>", c_smime_encrypt_with);
1149 }
1151 fputc(
'O', msg->
fp);
1153 {
1154 fputc(
'S', msg->
fp);
1155
1157 if (c_smime_sign_as)
1158 fprintf(msg->
fp,
"<%s>", c_smime_sign_as);
1159 }
1161 fputc(
'I', msg->
fp);
1162 fputc(
'\n', msg->
fp);
1163 }
1164
1165#ifdef MIXMASTER
1166
1167
1168
1170 {
1171 fputs(
"X-Mutt-Mix:", msg->
fp);
1174 {
1175 fprintf(msg->
fp,
" %s", (
char *) p->
data);
1176 }
1177
1178 fputc(
'\n', msg->
fp);
1179 }
1180#endif
1181
1182 if (fp_tmp)
1183 {
1185
1186
1187
1188 if (
mutt_file_seek(fp_tmp, -1, SEEK_END) && (fgetc(fp_tmp) !=
'\n') &&
1190 {
1191 fputc('\n', fp_tmp);
1192 }
1193
1194 fflush(fp_tmp);
1195 if (ferror(fp_tmp))
1196 {
1203 goto done;
1204 }
1205
1206
1207 int lines = 0;
1208 char line_buf[1024] = { 0 };
1209 rewind(fp_tmp);
1210 while (fgets(line_buf, sizeof(line_buf), fp_tmp))
1211 lines++;
1212 fprintf(msg->
fp,
"Content-Length: " OFF_T_FMT
"\n", (LOFF_T) ftello(fp_tmp));
1213 fprintf(msg->
fp,
"Lines: %d\n\n", lines);
1214
1215
1216 rewind(fp_tmp);
1219 rc = -1;
1220
1221 if (rc >= 0)
1222 {
1224 rc = 0;
1225 }
1226 }
1227 else
1228 {
1229 fputc(
'\n', msg->
fp);
1231 }
1232
1234 rc = -1;
1235 else if (finalpath)
1239
1240 if (!post && need_mailbox_cleanup)
1242
1243 if (post)
1245
1246done:
1247 m_fcc->
append = old_append;
1249
1250#ifdef RECORD_FOLDER_HOOK
1251
1252
1254 if (m_cur)
1256#endif
1257
1258 if (fp_tmp)
1259 {
1262 }
1264
1265 return rc;
1266}
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
void mutt_folder_hook(const char *path, const char *desc)
Perform a folder hook.
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
@ MUTT_MMDF
'mmdf' Mailbox type
@ MUTT_MBOX
'mbox' Mailbox type
void mutt_mailbox_cleanup(const char *path, struct stat *st)
Restore the timestamp of a mailbox.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
uint8_t MsgOpenFlags
Flags for mx_msg_open_new(), e.g. MUTT_ADD_FROM.
#define MUTT_ADD_FROM
add a From_ line
#define MUTT_SET_DRAFT
set the message draft flag
#define MUTT_APPEND
Open mailbox for appending messages.
#define MUTT_QUIET
Do not print any messages.
#define SEC_INLINE
Email has an inline signature.
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
#define SEC_AUTOCRYPT_OVERRIDE
(Autocrypt) Indicates manual set/unset of encryption
#define SEC_SIGN
Email is signed.
#define STAILQ_EMPTY(head)
struct ListHead chain
Mixmaster chain.
bool append
Mailbox is opened in append mode.
enum MailboxType type
Mailbox type.
struct ConfigSubset * sub
Inherited config items.
char * committed_path
the final path generated by mx_msg_commit()