You are here

public function PGPAnalyzer::analyze in Mailhandler 8

File

src/Plugin/inmail/Analyzer/PGPAnalyzer.php, line 37

Class

PGPAnalyzer
An analyzer for PGP signed messages.

Namespace

Drupal\mailhandler\Plugin\inmail\Analyzer

Code

public function analyze(MimeMessageInterface $message, ProcessorResultInterface $processor_result) {
  $result = $processor_result
    ->getAnalyzerResult();
  $context = [];

  // Check if we are dealing with PGP-signed message.
  if ($this
    ->isSigned($message, $result, $context)) {
    try {
      $this
        ->findSender($message, $result, $context);
      $this
        ->verifySignature($result);
      $this
        ->findBody($message, $result, $context);
    } catch (\Exception $e) {

      // Log error in case verification or authentication fails.
      \Drupal::logger('mailhandler')
        ->log(RfcLogLevel::WARNING, $e
        ->getMessage());
    }
  }
}