mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Globally limit the size of generated emails.
Summary: At the global level, truncate emails at a user-configured size. Test Plan: Untested, as I could not get PHP to send emails on my box, but if you can this should be very easy to test. Just set the max size to something like .001 kilobytes and make sure it does the right thing. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, AnhNhan Maniphest Tasks: T1392 Differential Revision: https://secure.phabricator.com/D6118
This commit is contained in:
parent
758586abda
commit
d78386584f
3 changed files with 21 additions and 0 deletions
|
@ -285,6 +285,10 @@ return array(
|
|||
// mostly never arrive.
|
||||
'metamta.can-send-as-user' => false,
|
||||
|
||||
// Limit the maximum size of the body of an email generated for a diff
|
||||
// (in bytes).
|
||||
'metamta.email-body-limit' => 524288,
|
||||
|
||||
// Adapter class to use to transmit mail to the MTA. The default uses
|
||||
// PHPMailerLite, which will invoke "sendmail". This is appropriate
|
||||
// if sendmail actually works on your host, but if you haven't configured mail
|
||||
|
|
|
@ -338,6 +338,17 @@ EODOC
|
|||
->addExample(
|
||||
'gwashington (George Washington) <gwashington@example.com>',
|
||||
'full'),
|
||||
$this->newOption('metamta.email-body-limit', 'int', 524288)
|
||||
->setDescription(
|
||||
pht(
|
||||
'You can set a limit for the maximum byte size of outbound mail. '.
|
||||
'Mail which is larger than this limit will be truncated before '.
|
||||
'being sent. This can be useful if your MTA rejects mail which '.
|
||||
'exceeds some limit (this is reasonably common). Specify a value '.
|
||||
'in bytes.'))
|
||||
->setSummary(pht('Global cap for size of generated emails (bytes).'))
|
||||
->addExample(524288, pht('Truncate at 512KB'))
|
||||
->addExample(1048576, pht('Truncate at 1MB'))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -445,6 +445,12 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
|
|||
}
|
||||
break;
|
||||
case 'body':
|
||||
$max = PhabricatorEnv::getEnvConfig('metamta.email-body-limit');
|
||||
if (strlen($value) > $max) {
|
||||
$value = phutil_utf8_shorten($value, $max);
|
||||
$value .= "\n";
|
||||
$value .= pht('(This email was truncated at %d bytes.)', $max);
|
||||
}
|
||||
$mailer->setBody($value);
|
||||
break;
|
||||
case 'subject':
|
||||
|
|
Loading…
Reference in a new issue