1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Don't set mail HTML bodies if there's no actual HTML body

Summary:
See <https://discourse.phabricator-community.org/t/commit-6011085b0fcd-breaks-sending-certain-email/1571>. Some mailers get upset if we `setHTMLBody(...)` with an empty string.

There's some possible argument they should be more graceful about this, but it's reasonably pretty ambiguous.

Only try to set the HTML body if we actually have a nonempty HTML body.

Test Plan:
  - Configured an "smtp" mailer.
  - Ran `echo hi | ./bin/mail send-test --to someone@somewhere.com --subject test`.
  - Before: error about empty message body.
  - After: no more message body error.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D19494
This commit is contained in:
epriestley 2018-06-15 12:03:28 -07:00
parent 1459fb3037
commit a7c681b549

View file

@ -917,13 +917,14 @@ final class PhabricatorMetaMTAMail
if ($send_html) { if ($send_html) {
$html_body = idx($params, 'html-body'); $html_body = idx($params, 'html-body');
if (strlen($html_body)) {
// NOTE: We just drop the entire HTML body if it won't fit. Safely // NOTE: We just drop the entire HTML body if it won't fit. Safely
// truncating HTML is hard, and we already have the text body to fall // truncating HTML is hard, and we already have the text body to fall
// back to. // back to.
if (strlen($html_body) <= $body_limit) { if (strlen($html_body) <= $body_limit) {
$mailer->setHTMLBody($html_body); $mailer->setHTMLBody($html_body);
$body_limit -= strlen($html_body); $body_limit -= strlen($html_body);
}
} }
} }