FS-5142 don't multipart/mixed if body has content-type present

This commit is contained in:
Brian West 2014-09-11 14:18:37 -05:00
parent 034bd1bf69
commit 80542e20f0
1 changed files with 31 additions and 20 deletions

View File

@ -808,11 +808,18 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
goto end; goto end;
} }
} }
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
if (!write_buf(fd, buf)) { if (!file && (!body || !switch_stristr("content-type", body))) {
rval = SWITCH_FALSE; bound = NULL;
err = "write error."; }
goto end;
if (bound) {
switch_snprintf(buf, B64BUFFLEN, "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"%s\"\n", bound);
if (!write_buf(fd, buf)) {
rval = SWITCH_FALSE;
err = "write error.";
goto end;
}
} }
if (headers && !write_buf(fd, headers)) { if (headers && !write_buf(fd, headers)) {
@ -827,15 +834,17 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
goto end; goto end;
} }
if (body && switch_stristr("content-type", body)) { if (bound) {
switch_snprintf(buf, B64BUFFLEN, "--%s\n", bound); if (body && switch_stristr("content-type", body)) {
} else { switch_snprintf(buf, B64BUFFLEN, "--%s\n", bound);
switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound); } else {
} switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound);
if (!write_buf(fd, buf)) { }
rval = SWITCH_FALSE; if (!write_buf(fd, buf)) {
err = "write error."; rval = SWITCH_FALSE;
goto end; err = "write error.";
goto end;
}
} }
if (body) { if (body) {
@ -846,7 +855,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
} }
} }
if (file) { if (file && bound) {
const char *stipped_file = switch_cut_path(file); const char *stipped_file = switch_cut_path(file);
const char *new_type; const char *new_type;
char *ext; char *ext;
@ -904,12 +913,14 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
} }
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound); if (bound) {
switch_snprintf(buf, B64BUFFLEN, "\n\n--%s--\n.\n", bound);
if (!write_buf(fd, buf)) { if (!write_buf(fd, buf)) {
rval = SWITCH_FALSE; rval = SWITCH_FALSE;
err = "write error."; err = "write error.";
goto end; goto end;
}
} }
} }