char *mailbcc = get_url_param(h, "mailbcc"); // Bcc:
if (!mailbcc) mailbcc = "";
- // If there are attachments, we have to merge them into the message text.
- char *att = get_url_param(h, "att");
- if (att) {
- syslog(LOG_DEBUG, "💥 There are attachments. Going multipart/mixed. <%s>", att);
- }
-
// Mode 4 will give us metadata back after upload
ctdl_printf(c, "ENT0 1|%s||4|%s||1|%s|%s|||%s|", mailto, subj, mailcc, mailbcc, wefw);
ctdl_readline(c, buf, sizeof buf);
// Remember, ctdl_printf() appends \n on its own, so when adding a CRLF newline, only use \r
// Or for a blank line, use ctdl_write() with \r\n
-
// 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());
ctdl_printf(c, "MIME-Version: 1.0\r");
ctdl_write(c, HKEY("\r\n"));
}
- // If there are attachments, close the multipart/mixed MIME container.
+ // If there are attachments, add them now.
if (att) {
- // FIXME actually attach the attachments here.
+ int i;
+ char attid[10];
+ struct uploaded_file one_att;
+ int num_attachments = num_tokens(att, ',');
+
+ for (i=0; i<num_attachments; ++i) {
+ extract_token(attid, att, i, ',', sizeof(attid));
+ one_att = pop_upload(attid);
+ syslog(LOG_DEBUG, "💥 attachment: %s", one_att.filename);
+ }
+
+ // Close the multipart/mixed MIME container.
ctdl_printf(c, "--%s--\r", mime_boundary);
}