public function execute($request)
 {
     $emailConfigurationService = new EmailConfigurationService();
     $this->form = new EmailConfigurationForm(array(), array(), true);
     $this->form->bind($request->getParameter($this->form->getName()));
     $emailConfiguration = $this->form->populateEmailConfiguration($request);
     $emailConfigurationService->saveEmailConfiguration($emailConfiguration);
     if ($request->getParameter('chkSendTestEmail')) {
         $emailService = new EmailService();
         $result = $emailService->sendTestEmail($request->getParameter('txtTestEmail'));
         if ($result) {
             $this->getUser()->setFlash('templateMessage', array('SUCCESS', __('Successfully Saved. Test Email Sent')));
         } else {
             $this->getUser()->setFlash('templateMessage', array('WARNING', __("Successfully Saved. Test Email Not Sent")));
         }
     } else {
         $this->getUser()->setFlash('templateMessage', array('SUCCESS', __(TopLevelMessages::SAVE_SUCCESS)));
     }
     $this->redirect('admin/listMailConfiguration');
 }
 public function execute($request)
 {
     $this->setForm(new EmailConfigurationForm());
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $this->form->save();
             if ($this->form->getValue('chkSendTestEmail') == 'on') {
                 $emailService = new EmailService();
                 $result = $emailService->sendTestEmail($this->form->getValue('txtTestEmail'));
                 if ($result) {
                     $this->getUser()->setFlash('success', __('Successfully Saved. Test Email Sent'));
                 } else {
                     $this->getUser()->setFlash('warning', __("Successfully Saved. Test Email Not Sent"));
                 }
             } else {
                 $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS));
             }
             $this->redirect('admin/listMailConfiguration');
         }
     }
 }