doulubashang6936 2019-08-06 18:21
浏览 63

如何解决发送邮件问题

І will try to send email but when i set the parameters for transportBuilder the page just reloads.

Through var_dump I learned that the page reloads before the sendMassage method. For the sender and recipient fields, I tried to set the value simply through a string.

Locatiion of email_templates = Vendor/Module/etc/email_templates Location of email template file = Vendor/Module/view/email/template.html

//Controller action

$this->inlineTranslation->suspend();
                $storeScope = ScopeInterface::SCOPE_STORE;
                $transport = $this->transportBuilder
                    ->setTemplateIdentifier('request_admin_email_answer_template')
                    ->setTemplateOptions(
                        [
                            'area' => FrontNameResolver::AREA_CODE,
                            'store' => Store::DEFAULT_STORE_ID,
                        ]
                    )
                    ->setTemplateVars(['data' => $postObject])
                    ->setFrom($this->scopeConfig->getValue(self::XML_SENDER_EMAIL, $storeScope))
                    ->addTo($model->getEmail());
                $transport = $transport->getTransport();
                $transport->sendMessage();
                $this->inlineTranslation->resume();

//email_templates.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
    <template id="request_admin_email_answer_template" label="Request price Answer" file="request_price_answer.html" type="text" module="Smile_Customer" area="adminhtml"/>
</config>

//request_price_answer.html

{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Your Request: %comment" comment=$data.comment}}

{{trans "Answer for your request: %answer" answer=$data.answer_content}}

As a result, the email should go, but for now the page just reloads.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 shape_predictor_68_face_landmarks.dat
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料