public function submitMessage()
    {
        $messageMapper = ($this->container->dataMapper)('MessageMapper');
        $email = $this->container->emailHandler;

        // Check honepot and if clean, then submit message
        if ('alt@example.com' === $this->request->getParsedBodyParam('alt-email')) {
            $message = $messageMapper->make();
            $message->name = $this->request->getParsedBodyParam('name');
            $message->email = $this->request->getParsedBodyParam('email');
            $message->message = $this->request->getParsedBodyParam('message');
            $messageMapper->save($message);

            // Send message to workflow email
            $siteName = empty($this->siteSettings['displayName']) ? 'PitonCMS' : $this->siteSettings['displayName'];
            $email->setTo($this->siteSettings['contactFormEmail'], '')
                    ->setSubject("New Contact Message to $siteName")
                    ->setMessage("From: {$message->email}\n\n{$message->message}")
                    ->send();
        }

        // Set the response type and return
        $r = $this->response->withHeader('Content-Type', 'application/json');
        return $r->write(json_encode(["response" => $this->siteSettings['contactFormAcknowledgement']]));
    }
public function submitMessage()
    {
        $messageMapper = ($this->container->dataMapper)('MessageMapper');
        $email = $this->container->emailHandler;

        // Check honepot and if clean, then submit message
        if ('alt@example.com' === $this->request->getParsedBodyParam('alt-email')) {
            $message = $messageMapper->make();
            $message->name = $this->request->getParsedBodyParam('name');
            $message->email = $this->request->getParsedBodyParam('email');
            $message->message = $this->request->getParsedBodyParam('message');
            $messageMapper->save($message);

            // Send message to workflow email
            $siteName = empty($this->siteSettings['displayName']) ? 'PitonCMS' : $this->siteSettings['displayName'];
            $email->setTo($this->siteSettings['contactFormEmail'], '')
                    ->setSubject("New Contact Message to $siteName")
                    ->setMessage("From: {$message->email}\n\n{$message->message}")
                    ->send();
        }

        // Set the response type and return
        $r = $this->response->withHeader('Content-Type', 'application/json');
        return $r->write(json_encode(["response" => $this->siteSettings['contactFormAcknowledgement']]));
    }
public function submitMessage ( ) { $ messageMapper = ( $ this -> container -> dataMapper ) ( 'MessageMapper' ) ; $ email = $ this -> container -> emailHandler ; // Check honepot and if clean, then submit message if ( 'alt@example.com' === $ this -> request -> getParsedBodyParam ( 'alt-email' ) ) { $ message = $ messageMapper -> make ( ) ; $ message -> name = $ this -> request -> getParsedBodyParam ( 'name' ) ; $ message -> email = $ this -> request -> getParsedBodyParam ( 'email' ) ; $ message -> message = $ this -> request -> getParsedBodyParam ( 'message' ) ; $ messageMapper -> save ( $ message ) ; // Send message to workflow email $ siteName = empty ( $ this -> siteSettings [ 'displayName' ] ) ? 'PitonCMS' : $ this -> siteSettings [ 'displayName' ] ; $ email -> setTo ( $ this -> siteSettings [ 'contactFormEmail' ] , '' ) -> setSubject ( "New Contact Message to $siteName" ) -> setMessage ( "From: {$message->email}\n\n{$message->message}" ) -> send ( ) ; } // Set the response type and return $ r = $ this -> response -> withHeader ( 'Content-Type' , 'application/json' ) ; return $ r -> write ( json_encode ( [ "response" => $ this -> siteSettings [ 'contactFormAcknowledgement' ] ] ) ) ; }
Submit Contact Message

@param POST array
Submit Contact Message