You are here

function mail_logger_load in Mail Logger 7

Same name and namespace in other branches
  1. 6 mail_logger.module \mail_logger_load()

Load a single email from the database.

Parameters

Int $id: The numeric ID of a logged email, which should match a mlid in the database.

Return value

Object|FALSE If a matching email is retrieved, all the data for that given email is returned, as provided by the DB.

1 call to mail_logger_load()
mail_logger_read_mail in ./mail_logger.pages.inc
Page callback at admin/reports/mail-logger/mail/xyz to show a single email.

File

./mail_logger.module, line 308
Mail Logger module logs all outgoing mail that passes through the drupal_mail function.

Code

function mail_logger_load($id) {
  $mail = db_select('mail_logger', 'ml')
    ->range(0, 1)
    ->fields('ml')
    ->condition('mlid', $id)
    ->execute()
    ->fetchObject();
  if ($mail) {

    // Alter encrypted mail log records back to their original state.
    $context = array(
      'operation' => 'read',
    );
    drupal_alter('mail_logger_record', $mail, $context);
    $mail->headers = unserialize($mail->headers);
    return $mail;
  }
  else {
    return FALSE;
  }
}