<?php
class ClassEmail extends ClassTranslation implements InterfaceEmail {
    public function __construct(){}
    public function __destruct(){}
    
  public function sendEmail($exp, $dest, $subject, $content, $headers){
    $this->_exp = $exp;
    $this->_dest = $dest;
    $this->_subject = $subject;
    $this->_content = $content;
    
    $header = "MIME-Version: 1.0\r\n";
    $header .= "Content-type: text/html; charset=utf-8-1\r\n";
    $header .= "From: ".$this->_exp."\r\n";
    
    $res = array();
    if(mail($this->_dest,
            $this->_subject,
            $this->_content, $header)){
        $res['state'] = 'success';
    } else{
        $res['state'] = 'failed';
    }
    
    return $res;
  }
  
    public function getMessage($message_code, $lang_code, $set_data){
        $this->_messageCode = $message_code;
        $this->_langCode = $lang_code;
        $this->_setData = $set_data;
        $oTrans = new ClassTranslation();
        
        $message = $oTrans->getTranslation($this->_messageCode, $this->_langCode);
        $replacement_regex = '/\[data\]/';
        
        foreach($this->_setData as $k=>$v){
            $message = preg_replace($replacement_regex, $this->_setData[$k], $message, 1);
        }
        
        return $message;
    }
    
    
}
