<?php

namespace HwapX\Core\Library;

class SMTP extends \SMTP {
    function send($message,$log=TRUE,$mock=FALSE) {
        $headers=$this->headers;

        if(isset($this->headers['Subject'])) {
            $preferences = ["input-charset" => "UTF-8", "output-charset" => "UTF-8"];
            $this->headers['Subject'] = substr(iconv_mime_encode("Subject", $this->headers['Subject'], $preferences), 9);
        }

        $result = parent::send($message, $log, $mock);

        $this->headers = $headers;

        return $result;
    }
}
