transport = $mailjetTransport ; $this->templating = $templating ; $this->parameterBag = $parameterBag ; $this->merchantUtils = $merchantUtils ; } public function send($params = []) { $merchantCurrent = $this->merchantUtils->getMerchantCurrent() ; $merchantConfigEmailFrom = $merchantCurrent->getMerchantConfig('email-from') ; $emailFrom = isset($params[self::FROM_EMAIL]) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom ; $merchantConfigEmailFromName = $merchantCurrent->getMerchantConfig('email-from-name') ; $emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName ; $merchantConfigEmailSubjectPrefix = $merchantCurrent->getMerchantConfig('email-subject-prefix') ; $emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ? $params[self::SUBJECT_PREFIX] : $merchantConfigEmailSubjectPrefix ; if($emailSubjectPrefix && strlen($emailSubjectPrefix)) { $emailSubjectPrefix .= ' ' ; } $message = new \Swift_Message($emailSubjectPrefix.$params[self::SUBJECT]); $message->addTo( $params[self::TO_EMAIL], isset($params[self::TO_NAME]) ? $params[self::TO_NAME] : null) ->addFrom($emailFrom, $emailFromName) ->setBody($this->templating->render($params[self::CONTENT_TEMPLATE].'-html.html.twig', $params[self::CONTENT_DATA]), 'text/html') ->addPart($this->templating->render($params[self::CONTENT_TEMPLATE].'-text.html.twig', $params[self::CONTENT_DATA])); if(isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) { $message->addReplyTo($params[self::REPLY_TO]) ; } if(isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) { $message->attach(\Swift_Attachment::newInstance( $params[self::ATTACHMENT_DATA], $params[self::ATTACHMENT_FILENAME], $params[self::ATTACHMENT_CONTENT_TYPE] )); } $this->transport->send($message) ; } }