public static function pushEmail($name, $to, array $params = [], $fromName = null, $replyTo = null, $subject = null, $sendAfter = null, array $attachments = [])
    {
        //brak definicji
        if (null === ($def = Orm\CmsMailDefinitionQuery::langByName($name)
            ->findFirst())) {
            return false;
        }
        //walidacja listy adresów "do"
        $email = new \Mmi\Validator\EmailAddressList;
        if (!$email->isValid($to)) {
            return false;
        }
        //nowy rekord maila
        $mail = new Orm\CmsMailRecord;
        $mail->cmsMailDefinitionId = $def->id;
        $mail->to = $to;
        $mail->fromName = $fromName ? $fromName : $def->fromName;
        $mail->replyTo = $replyTo ? $replyTo : $def->replyTo;
        $mail->subject = $subject ? $subject : $def->subject;
        $mail->dateSendAfter = $sendAfter ? $sendAfter : date('Y-m-d H:i:s');
        $files = [];
        //załączniki
        foreach ($attachments as $fileName => $filePath) {
            if (!file_exists($filePath)) {
                continue;
            }
            $files[$fileName] = ($filePath);
        }
        //serializacja załączników
        $mail->attachements = serialize($files);
        //przepychanie zmiennych do widoku
        $view = \Mmi\App\FrontController::getInstance()->getView();
        foreach ($params as $key => $value) {
            $view->$key = $value;
        }
        //rendering wiadomości
        $mail->message = $view->renderDirectly($def->message);
        //rendering tematu
        $mail->subject = $view->renderDirectly($mail->subject);
        $mail->dateAdd = date('Y-m-d H:i:s');
        //zapis maila
        return $mail->save();
    }
public static function pushEmail($name, $to, array $params = [], $fromName = null, $replyTo = null, $subject = null, $sendAfter = null, array $attachments = [])
    {
        //brak definicji
        if (null === ($def = Orm\CmsMailDefinitionQuery::langByName($name)
            ->findFirst())) {
            return false;
        }
        //walidacja listy adresów "do"
        $email = new \Mmi\Validator\EmailAddressList;
        if (!$email->isValid($to)) {
            return false;
        }
        //nowy rekord maila
        $mail = new Orm\CmsMailRecord;
        $mail->cmsMailDefinitionId = $def->id;
        $mail->to = $to;
        $mail->fromName = $fromName ? $fromName : $def->fromName;
        $mail->replyTo = $replyTo ? $replyTo : $def->replyTo;
        $mail->subject = $subject ? $subject : $def->subject;
        $mail->dateSendAfter = $sendAfter ? $sendAfter : date('Y-m-d H:i:s');
        $files = [];
        //załączniki
        foreach ($attachments as $fileName => $filePath) {
            if (!file_exists($filePath)) {
                continue;
            }
            $files[$fileName] = ($filePath);
        }
        //serializacja załączników
        $mail->attachements = serialize($files);
        //przepychanie zmiennych do widoku
        $view = \Mmi\App\FrontController::getInstance()->getView();
        foreach ($params as $key => $value) {
            $view->$key = $value;
        }
        //rendering wiadomości
        $mail->message = $view->renderDirectly($def->message);
        //rendering tematu
        $mail->subject = $view->renderDirectly($mail->subject);
        $mail->dateAdd = date('Y-m-d H:i:s');
        //zapis maila
        return $mail->save();
    }
public static function pushEmail ( $ name , $ to , array $ params = [ ] , $ fromName = null , $ replyTo = null , $ subject = null , $ sendAfter = null , array $ attachments = [ ] ) { //brak definicji if ( null === ( $ def = Orm \ CmsMailDefinitionQuery :: langByName ( $ name ) -> findFirst ( ) ) ) { return false ; } //walidacja listy adresów "do" $ email = new \ Mmi \ Validator \ EmailAddressList ; if ( ! $ email -> isValid ( $ to ) ) { return false ; } //nowy rekord maila $ mail = new Orm \ CmsMailRecord ; $ mail -> cmsMailDefinitionId = $ def -> id ; $ mail -> to = $ to ; $ mail -> fromName = $ fromName ? $ fromName : $ def -> fromName ; $ mail -> replyTo = $ replyTo ? $ replyTo : $ def -> replyTo ; $ mail -> subject = $ subject ? $ subject : $ def -> subject ; $ mail -> dateSendAfter = $ sendAfter ? $ sendAfter : date ( 'Y-m-d H:i:s' ) ; $ files = [ ] ; //załączniki foreach ( $ attachments as $ fileName => $ filePath ) { if ( ! file_exists ( $ filePath ) ) { continue ; } $ files [ $ fileName ] = ( $ filePath ) ; } //serializacja załączników $ mail -> attachements = serialize ( $ files ) ; //przepychanie zmiennych do widoku $ view = \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) ; foreach ( $ params as $ key => $ value ) { $ view -> $ key = $ value ; } //rendering wiadomości $ mail -> message = $ view -> renderDirectly ( $ def -> message ) ; //rendering tematu $ mail -> subject = $ view -> renderDirectly ( $ mail -> subject ) ; $ mail -> dateAdd = date ( 'Y-m-d H:i:s' ) ; //zapis maila return $ mail -> save ( ) ; }
Dodaje email do kolejki
@param string $name nazwa-klucz e-maila z definicji
@param string $to adres do lub adresy oddzielone ";"
@param array $params zmienne do podstawienia w treści maila
@param string $fromName nazwa od
@param string $replyTo adres odpowiedz do
@param string $subject temat
@param string $sendAfter data i czas wyślij po
@param array $attachments tabela z załącznikami w postaci ['nazwa dla usera' => 'fizyczna ścieżka i nazwa pliku']
@return int id zapisanego rekordu
Dodaje email do kolejki