<commit_before><?php

class CM_Mail_Mailer extends Swift_Mailer implements CM_Service_ManagerAwareInterface {

    use CM_Service_ManagerAwareTrait;

    public function __construct(Swift_Transport $transport) {
        CM_Mail_Message::register();
        parent::__construct($transport);
    }

    public function send(Swift_Mime_Message $message, &$failedRecipients = null) {
        $failedRecipients = (array) $failedRecipients;
        $to = $message->getTo();
        if (empty($to)) {
            throw new CM_Exception_Invalid('No recipient specified');
        }
        $numSent = parent::send($message, $failedRecipients);
        if (0 === $numSent || 0 !== count($failedRecipients)) {
            $context = new CM_Log_Context();
            $context->setExtra([
                'message'          => [
                    'subject' => $message->getSubject(),
                    'from'    => $message->getSender(),
                    'to'      => $message->getTo(),
                    'cc'      => $message->getCc(),
                    'bcc'     => $message->getBcc(),
                ],
                'failedRecipients' => $failedRecipients,
            ]);
            $this->getServiceManager()->getLogger()->error('Failed to send email to all recipients', $context);
        }
        return $numSent;
    }

    public function createMessage($service = null) {
        $service = null === $service ? 'cm-message' : $service;
        return parent::createMessage($service);
    }
}<commit_msg>Stop mail transport after sending<commit_after><?php

class CM_Mail_Mailer extends Swift_Mailer implements CM_Service_ManagerAwareInterface {

    use CM_Service_ManagerAwareTrait;

    public function __construct(Swift_Transport $transport) {
        CM_Mail_Message::register();
        parent::__construct($transport);
    }

    public function send(Swift_Mime_Message $message, &$failedRecipients = null) {
        $failedRecipients = (array) $failedRecipients;
        $to = $message->getTo();
        if (empty($to)) {
            throw new CM_Exception_Invalid('No recipient specified');
        }

        $numSent = 0;
        $failedRecipients = null;
        $context = new CM_Log_Context();
        try {
            $numSent = parent::send($message, $failedRecipients);
        } catch (Exception $e) {
            $context->setException($e);
            throw $e;
        }

        $this->getTransport()->stop();

        $succeeded = 0 !== $numSent && null !== $failedRecipients && 0 === count($failedRecipients);
        if (!$succeeded) {
            $context->setExtra([
                'message'          => [
                    'subject' => $message->getSubject(),
                    'from'    => $message->getFrom(),
                    'to'      => $message->getTo(),
                    'cc'      => $message->getCc(),
                    'bcc'     => $message->getBcc(),
                ],
                'failedRecipients' => $failedRecipients,
            ]);
            $this->getServiceManager()->getLogger()->error('Failed to send email', $context);
        }

        return $numSent;
    }

    public function createMessage($service = null) {
        $service = null === $service ? 'cm-message' : $service;
        return parent::createMessage($service);
    }
}
{'fraction_non_alphanumeric': 0.1371308016877637, 'fraction_numerical': 0.0015069318866787222, 'mean_word_length': 2.0505514705882355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7558217', 'n_tokens_mistral': 919, 'n_tokens_neox': 863, 'n_words': 175}