src/SspContact/Service/ContactService.php
public function sendMessage(Contact $contactMessage)
    {
        $serverName = ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);

        // PREPARE THE EMAIL MESSAGE
        $message = new Message();
        $message->addFrom(new Address($contactMessage->getEmail(), $contactMessage->getFirstName() . ' ' . $contactMessage->getLastName()));
        $message->setSubject($contactMessage->getSubject());

        $body = <<<MSG
New Message \n
From: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \n
Subject: [$serverName contact] {$contactMessage->getSubject()} \n
Message: {$contactMessage->getMessage()} \n
MSG;

        $message->setBody($body);

        // SEND THE EMAIL
        return $this->getServiceLocator()->get('transport')->send($message);
    }
public function sendMessage(Contact $contactMessage)
    {
        $serverName = ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);

        // PREPARE THE EMAIL MESSAGE
        $message = new Message();
        $message->addFrom(new Address($contactMessage->getEmail(), $contactMessage->getFirstName() . ' ' . $contactMessage->getLastName()));
        $message->setSubject($contactMessage->getSubject());

        $body = <<<MSG
New Message \n
From: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \n
Subject: [$serverName contact] {$contactMessage->getSubject()} \n
Message: {$contactMessage->getMessage()} \n
MSG;

        $message->setBody($body);

        // SEND THE EMAIL
        return $this->getServiceLocator()->get('transport')->send($message);
    }
public function sendMessage ( Contact $ contactMessage ) { $ serverName = ( $ _SERVER [ 'HTTP_HOST' ] ? $ _SERVER [ 'HTTP_HOST' ] : $ _SERVER [ 'SERVER_NAME' ] ) ; // PREPARE THE EMAIL MESSAGE $ message = new Message ( ) ; $ message -> addFrom ( new Address ( $ contactMessage -> getEmail ( ) , $ contactMessage -> getFirstName ( ) . ' ' . $ contactMessage -> getLastName ( ) ) ) ; $ message -> setSubject ( $ contactMessage -> getSubject ( ) ) ; $ body =  <<<MSG
New Message \n
From: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \n
Subject: [$serverName contact] {$contactMessage->getSubject()} \n
Message: {$contactMessage->getMessage()} \n
MSG ; $ message -> setBody ( $ body ) ; // SEND THE EMAIL return $ this -> getServiceLocator ( ) -> get ( 'transport' ) -> send ( $ message ) ; }
Composes & sends the email from a contact message
@param Contact $contactMessage
@return mixed
Composes & sends the email from a contact message