public function sendAction()
    {
        $contactForm = $this->createForm(FrontForm::CONTACT);
        
        try {
            $form = $this->validateForm($contactForm);

            $event = new ContactEvent($form);

            $this->dispatch(TheliaEvents::CONTACT_SUBMIT, $event);

            $this->getMailer()->sendSimpleEmailMessage(
                [ ConfigQuery::getStoreEmail() => $event->getName() ],
                [ ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName() ],
                $event->getSubject(),
                '',
                $event->getMessage(),
                [],
                [],
                [ $event->getEmail() => $event->getName() ]
            );

            if ($contactForm->hasSuccessUrl()) {
                return $this->generateSuccessRedirect($contactForm);
            }
            
            return $this->generateRedirectFromRoute('contact.success');
            
        } catch (FormValidationException $e) {
            $error_message = $e->getMessage();
        }
        
        Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message));
        
        $contactForm->setErrorMessage($error_message);
        
        $this->getParserContext()
            ->addForm($contactForm)
            ->setGeneralError($error_message)
        ;
        
        // Redirect to error URL if defined
        if ($contactForm->hasErrorUrl()) {
            return $this->generateErrorRedirect($contactForm);
        }
    }
public function sendAction()
    {
        $contactForm = $this->createForm(FrontForm::CONTACT);
        
        try {
            $form = $this->validateForm($contactForm);

            $event = new ContactEvent($form);

            $this->dispatch(TheliaEvents::CONTACT_SUBMIT, $event);

            $this->getMailer()->sendSimpleEmailMessage(
                [ ConfigQuery::getStoreEmail() => $event->getName() ],
                [ ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName() ],
                $event->getSubject(),
                '',
                $event->getMessage(),
                [],
                [],
                [ $event->getEmail() => $event->getName() ]
            );

            if ($contactForm->hasSuccessUrl()) {
                return $this->generateSuccessRedirect($contactForm);
            }
            
            return $this->generateRedirectFromRoute('contact.success');
            
        } catch (FormValidationException $e) {
            $error_message = $e->getMessage();
        }
        
        Tlog::getInstance()->error(sprintf('Error during sending contact mail : %s', $error_message));
        
        $contactForm->setErrorMessage($error_message);
        
        $this->getParserContext()
            ->addForm($contactForm)
            ->setGeneralError($error_message)
        ;
        
        // Redirect to error URL if defined
        if ($contactForm->hasErrorUrl()) {
            return $this->generateErrorRedirect($contactForm);
        }
    }
public function sendAction ( ) { $ contactForm = $ this -> createForm ( FrontForm :: CONTACT ) ; try { $ form = $ this -> validateForm ( $ contactForm ) ; $ event = new ContactEvent ( $ form ) ; $ this -> dispatch ( TheliaEvents :: CONTACT_SUBMIT , $ event ) ; $ this -> getMailer ( ) -> sendSimpleEmailMessage ( [ ConfigQuery :: getStoreEmail ( ) => $ event -> getName ( ) ] , [ ConfigQuery :: getStoreEmail ( ) => ConfigQuery :: getStoreName ( ) ] , $ event -> getSubject ( ) , '' , $ event -> getMessage ( ) , [ ] , [ ] , [ $ event -> getEmail ( ) => $ event -> getName ( ) ] ) ; if ( $ contactForm -> hasSuccessUrl ( ) ) { return $ this -> generateSuccessRedirect ( $ contactForm ) ; } return $ this -> generateRedirectFromRoute ( 'contact.success' ) ; } catch ( FormValidationException $ e ) { $ error_message = $ e -> getMessage ( ) ; } Tlog :: getInstance ( ) -> error ( sprintf ( 'Error during sending contact mail : %s' , $ error_message ) ) ; $ contactForm -> setErrorMessage ( $ error_message ) ; $ this -> getParserContext ( ) -> addForm ( $ contactForm ) -> setGeneralError ( $ error_message ) ; // Redirect to error URL if defined if ( $ contactForm -> hasErrorUrl ( ) ) { return $ this -> generateErrorRedirect ( $ contactForm ) ; } }
send contact message
send contact message