/**
* Will write log to database
* @param boolean $result
* @param MessageInterface $message
*/
public function createLog($result, $message)
{
$mail = new Mail();
$mail->estado = $result ? Mail::IS_SENT : Mail::IS_NOT_SENT;
$mail->created_at = time();
$mail->controller = \Yii::$app->controller->id;
$mail->action = \Yii::$app->controller->action->id;
$temp = [];
//store emails as string
foreach ($message->getTo() as $email => $name) {
$temp[] = $email;
}
$mail->emails = implode(', ', $temp);
$mail->body = $message->toString();
$mail->save();
}