1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Make HTML email a little easier to debug

Summary:
Ref T992.

  - Format text/HTML bodies explicitly in `bin/mail show-outbound`.
  - Provide `bin/mail show-outbound --dump-html` so you can do something like `bin/mail show-outbound --dump-html > dump.html; open dump.html` to get a browser preview somewhat easily.

Test Plan: Ran `bin/mail show-outbound` with and without `--dump-html` flag.

Reviewers: talshiri, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T992

Differential Revision: https://secure.phabricator.com/D10272
This commit is contained in:
epriestley 2014-08-15 11:07:33 -07:00
parent eb3ed9bbc9
commit 8403812e15
2 changed files with 43 additions and 2 deletions

View file

@ -17,6 +17,12 @@ final class PhabricatorMailManagementShowOutboundWorkflow
'help' => 'Show details about outbound mail with given ID.',
'repeat' => true,
),
array(
'name' => 'dump-html',
'help' => pht(
'Dump the HTML body of the mail. You can redirect it to a '.
'file and then open it in a browser.'),
),
));
}
@ -45,6 +51,20 @@ final class PhabricatorMailManagementShowOutboundWorkflow
$last_key = last_key($messages);
foreach ($messages as $message_key => $message) {
if ($args->getArg('dump-html')) {
$html_body = $message->getHTMLBody();
if (strlen($html_body)) {
$template =
"<!doctype html><html><body>{$html_body}</body></html>";
$console->writeOut("%s\n", $html_body);
} else {
$console->writeErr(
"%s\n",
pht('(This message has no HTML body.)'));
}
continue;
}
$info = array();
$info[] = pht('PROPERTIES');
@ -61,6 +81,10 @@ final class PhabricatorMailManagementShowOutboundWorkflow
continue;
}
if ($key == 'html-body') {
continue;
}
if ($key == 'headers') {
continue;
}
@ -110,8 +134,21 @@ final class PhabricatorMailManagementShowOutboundWorkflow
}
$info[] = null;
$info[] = pht('BODY');
$info[] = $message->getBody();
$info[] = pht('TEXT BODY');
if (strlen($message->getBody())) {
$info[] = $message->getBody();
} else {
$info[] = pht('(This message has no text body.)');
}
$info[] = null;
$info[] = pht('HTML BODY');
if (strlen($message->getHTMLBody())) {
$info[] = $message->getHTMLBody();
$info[] = null;
} else {
$info[] = pht('(This message has no HTML body.)');
}
$console->writeOut('%s', implode("\n", $info));

View file

@ -221,6 +221,10 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
return $this->getParam('body');
}
public function getHTMLBody() {
return $this->getParam('html-body');
}
public function setIsErrorEmail($is_error) {
$this->setParam('is-error', $is_error);
return $this;