// If there are attachments, open up a multipart/mixed MIME container.
char *att = get_url_param(h, "att");
if (att) {
- snprintf(mime_boundary, sizeof(mime_boundary), "citadel-multipart-%x-%x", time(NULL), rand());
+ snprintf(mime_boundary, sizeof(mime_boundary), "citadel-multipart-%x-%x", (unsigned int)time(NULL), rand());
ctdl_printf(c, "MIME-Version: 1.0\r");
ctdl_printf(c, "Content-Type: multipart/mixed; boundary=\"%s\"\r", mime_boundary);
ctdl_write(c, HKEY("\r\n"));
extract_token(attid, att, i, ',', sizeof(attid));
one_att = pop_upload(attid);
syslog(LOG_DEBUG, "💥 attachment: %s", one_att.filename);
+ ctdl_printf(c, "--%s--\r", mime_boundary);
+ ctdl_printf(c, "Content-Type: %s; name=\"%s\"\r", one_att.content_type, one_att.filename);
+ ctdl_printf(c, "Content-Disposition: attachment; filename=\"%s\"\r", one_att.filename);
+ ctdl_printf(c, "Content-Transfer-Encoding: base64\r");
+ ctdl_write(c, HKEY("\r\n"));
+
+ char *raw_att = malloc(one_att.length);
+ if (raw_att) {
+ fread(raw_att, one_att.length, 1, one_att.fp);
+
+ // now encode it
+
+ }
+
+ fclose(one_att.fp);
}
// Close the multipart/mixed MIME container.