diff --git a/commercemailer/controllers/CommerceMailerController.php b/commercemailer/controllers/CommerceMailerController.php index 768de69..85be1d1 100644 --- a/commercemailer/controllers/CommerceMailerController.php +++ b/commercemailer/controllers/CommerceMailerController.php @@ -119,12 +119,12 @@ public function actionSendMail() } $compiledMessage .= $postedMessage['body']; } - $vars['body'] = $compiledMessage; + $vars['body'] = "
" . nl2br($compiledMessage); } } else { - $vars['body'] = $postedMessage; + $vars['body'] = "
" . nl2br($postedMessage); } } @@ -132,6 +132,14 @@ public function actionSendMail() // create an EmailModel & populate it $email = EmailModel::populateModel($vars); + //Attach a file if there is one... + $attachment = null; + if (isset($_FILES['attachment']) && !empty($_FILES['attachment']['name'])) + { + CommerceMailerPlugin::log("Found attachment " . $_FILES['attachment']['name']); + $attachment = \CUploadedFile::getInstanceByName('attachment'); + $email->addAttachment($attachment->getTempName(), $attachment->getName(), 'base64', $attachment->getType()); + } //validate the email model //put all our errors in one place, and return the email model if invalid - use message as this is what contactForm does @@ -185,6 +193,8 @@ public function actionSendMail() foreach ($errors as $error) { CommerceMailerPlugin::logError($error); } + //Log what page the error happened on... + CommerceMailerPlugin::logError(craft()->request->getUrlReferrer()); craft()->urlManager->setRouteVariables(['errors' => $errors, 'message' => $email] ); } else { @@ -195,7 +205,7 @@ public function actionSendMail() if (!$spam){ //Special sauce for us.... - if (craft()->config->get('environmentVariables')['customMessaging']){ + if (craft()->config->get('environmentVariables')['IsImageScience']){ //Are we sending to a local address? if(strpos($email->toEmail, "@" . $settings->internalDomain) === false){ @@ -205,7 +215,7 @@ public function actionSendMail() } else{ //Make a freshdesk ticket with the API - $sent = craft()->businessLogic_freshdesk->ticket($email->fromEmail, $email->toEmail, $email->subject, $email->htmlBody, (isset($vars['order']) ? $vars['order'] : null) ); + $sent = craft()->businessLogic_freshdesk->ticket($email->fromEmail, $email->toEmail, $email->subject, $email->htmlBody, (isset($vars['order']) ? $vars['order'] : null), false, $attachment); } }