function devel_mail_logger_show_mail in Devel Mail Logger 7
Function allows rendering of the mails.
Parameters
$mail:
Return value
string
Throws
Exception
1 string reference to 'devel_mail_logger_show_mail'
- devel_mail_logger_menu in ./
devel_mail_logger.module - Implements hook_menu().
File
- ./
devel_mail_logger.admin.inc, line 84
Code
function devel_mail_logger_show_mail($mail) {
$mail = json_decode($mail->message);
$rows = array();
foreach ($mail->headers as $key => $value) {
$rows[] = array(
array(
'data' => $key,
'header' => true,
),
$value,
);
}
$build['headers'] = array(
'#type' => 'fieldset',
'#title' => 'Headers',
'#collapsed' => TRUE,
'#collapsible' => TRUE,
);
$build['headers']['table'] = array(
'#theme' => 'table',
//'#header' => $header,
'#rows' => $rows,
);
$system = drupal_mail_system($mail->module, $mail->key);
$message = $system
->format((array) $mail);
$body = $message['params']->body[0];
$rows = array(
array(
array(
'data' => t('To: '),
'header' => TRUE,
),
t($mail->to),
),
array(
array(
'data' => t('From: '),
'header' => TRUE,
),
t($mail->from),
),
array(
array(
'data' => t('Subject: '),
'header' => TRUE,
),
t($mail->subject),
),
array(
array(
'data' => t('Body: '),
'header' => TRUE,
),
$body,
),
);
$build['mail_table'] = [
'#theme' => 'table',
'#rows' => $rows,
];
return $build;
$output = '';
$output .= '<b>' . t('Subject:') . '</b> ' . $mail->subject;
$output .= '<br/>';
$message = json_decode($mail->message);
$system = drupal_mail_system($message->module, $message->key);
$message = $system
->format((array) $message);
$output .= '<b>' . t('Body') . '</b> ' . $message['body'];
return $output;
}