/** * Assumes before calling this, the sendgrid settings have been validated in the form. */ protected function processSendTestMessageForSendGrid() { $configurationForm = SendGridWebApiConfigurationFormAdapter::makeFormFromGlobalConfiguration(); if (isset($_POST['UserSendGridConfigurationForm'])) { $configurationForm->username = $_POST['UserSendGridConfigurationForm']['apiUsername']; $configurationForm->password = $_POST['UserSendGridConfigurationForm']['apiPassword']; $configurationForm->aTestToAddress = $_POST['UserSendGridConfigurationForm']['aTestToAddress']; $fromNameToSendMessagesFrom = $_POST['UserEmailConfigurationForm']['fromName']; $fromAddressToSendMessagesFrom = $_POST['UserEmailConfigurationForm']['fromAddress']; $messageContent = SendGridUtil::sendTestMessage($configurationForm, $fromNameToSendMessagesFrom, $fromAddressToSendMessagesFrom); Yii::app()->getClientScript()->setToAjaxMode(); $messageView = new TestConnectionView($messageContent); $view = new ModalView($this, $messageView); echo $view->render(); Yii::app()->end(); } else { throw new NotSupportedException(); } }
/** * Assumes before calling this, the sendgrid settings have been validated in the form. */ public function actionSendTestMessage() { $configurationForm = SendGridWebApiConfigurationFormAdapter::makeFormFromGlobalConfiguration(); $postVariableName = get_class($configurationForm); if (isset($_POST[$postVariableName])) { if (isset($_POST[$postVariableName])) { $configurationForm->setAttributes($_POST[$postVariableName]); } $messageContent = SendGridUtil::sendTestMessage($configurationForm); Yii::app()->getClientScript()->setToAjaxMode(); $messageView = new TestConnectionView($messageContent); $view = new ModalView($this, $messageView); echo $view->render(); } else { throw new NotSupportedException(); } }