![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-contact/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Contact\Model; use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Framework\Translate\Inline\StateInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\Area; class Mail implements MailInterface { /** * @var ConfigInterface */ private $contactsConfig; /** * @var TransportBuilder */ private $transportBuilder; /** * @var StateInterface */ private $inlineTranslation; /** * @var StoreManagerInterface */ private $storeManager; /** * Initialize dependencies. * * @param ConfigInterface $contactsConfig * @param TransportBuilder $transportBuilder * @param StateInterface $inlineTranslation * @param StoreManagerInterface|null $storeManager */ public function __construct( ConfigInterface $contactsConfig, TransportBuilder $transportBuilder, StateInterface $inlineTranslation, StoreManagerInterface $storeManager = null ) { $this->contactsConfig = $contactsConfig; $this->transportBuilder = $transportBuilder; $this->inlineTranslation = $inlineTranslation; $this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class); } /** * Send email from contact form * * @param string $replyTo * @param array $variables * @return void */ public function send($replyTo, array $variables) { /** @see \Magento\Contact\Controller\Index\Post::validatedParams() */ $replyToName = !empty($variables['data']['name']) ? $variables['data']['name'] : null; $this->inlineTranslation->suspend(); try { $transport = $this->transportBuilder ->setTemplateIdentifier($this->contactsConfig->emailTemplate()) ->setTemplateOptions( [ 'area' => Area::AREA_FRONTEND, 'store' => $this->storeManager->getStore()->getId() ] ) ->setTemplateVars($variables) ->setFrom($this->contactsConfig->emailSender()) ->addTo($this->contactsConfig->emailRecipient()) ->setReplyTo($replyTo, $replyToName) ->getTransport(); $transport->sendMessage(); } finally { $this->inlineTranslation->resume(); } } }