<commit_before><?php
namespace core\controllers;

use Yii;
use yii\db\Query;
use core\models\Email;
use Mandrill;
/**
 * Import controller
 */
class NotificationController extends \yii\console\Controller
{
    public function actionIndex()
    {
        $emails = Email::find()->where('status="pending" AND tries<10')->all();
        foreach($emails as $email) {
            $mandrill = new Mandrill(Yii::$app->params['mandrill']['key']);
            $message = array(
                'html' => $email->html,
                'text' => $email->text,
                'subject' => $email->subject,
                'from_email' => $email->from_email,
                'from_name' => $email->from_name,
                'track_opens' => true,
                'track_clicks' => true,
                'auto_text' => true,
                'to'=>array(array('email' => $email->to_email, 'name' => $email->to_name))
            ); 
            $email->detachBehavior('blameable');
              
            $result = $mandrill->messages->send($message);
            
            if($result[0]['status'] == 'sent') {
                $email->status = 'sent';
            } else {
                $email->tries++;
            }
            $email->save(false);
        }
    }    
}<commit_msg>changing the notification to use the new mailer<commit_after><?php
namespace core\controllers;

use Yii;
use yii\db\Query;
use core\models\Email;
/**
 * Import controller
 */
class NotificationController extends \yii\console\Controller
{
    public function actionIndex()
    {
        $emails = Email::find()->where('status="pending" AND tries<10')->all();
        foreach($emails as $email) {
            if(\Yii::$app->mailer->compose()
                ->setHtmlBody($email->html)
                ->setFrom($email->from_email)
                ->setTo($email->to_email)
                ->setSubject($email->subject)
                ->send()) {
                $email->status = 'sent';
            } else {
                $email->tries++;
            }
            $email->detachBehavior('blameable');
            $email->save(false);
        }   
    }    
}
{'fraction_non_alphanumeric': 0.1606725829051845, 'fraction_numerical': 0.002335357309668379, 'mean_word_length': 1.7532133676092545, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '5435281', 'n_tokens_mistral': 623, 'n_tokens_neox': 598, 'n_words': 106}