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:
parent
1459fb3037
commit
a7c681b549
1 changed files with 8 additions and 7 deletions
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue