更改“从” magento 联系表单电子邮件发送给发件人的字段

发布于 2024-11-10 12:40:38 字数 385 浏览 2 评论 0原文

如何将联系表单电子邮件的“发件人”字段更改为发件人的字段?例如,如果客户要使用电子邮件地址 '[email protected] 填写表单',如何使生成的电子邮件来自'[电子邮件受保护]'?

我查看了系统管理面板中的“电子邮件发件人”字段,但这仅允许一系列预设的商店电子邮件。

非常感谢

How would one go about changing the 'From' field of the contact form email to that of the sender's? For instance, if a customer was to fill in the form with the email '[email protected]', how can I make the generated email be from '[email protected]'?

I've looked at the 'email sender' field in the system admin panels, but this only allows for a range of preset store emails.

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帥小哥 2024-11-17 12:40:38

发送此消息的位置位于 app/code/core/Mage/Contacts/controllers/IndexController.php 中的第 100 行左右。看起来电子邮件的回复地址已设置为帖子中的电子邮件地址,因此,如果您只是想获得更简单的回复,我建议不要欺骗它。

您可能会看到的另一个问题是,使用欺骗性的“发件人”地址发送电子邮件可能会导致您的网站很快被许多电子邮件提供商列入黑名单,这可能会影响您的其他业务。

也就是说,如果您仍然想这样做,请在该文件中稍微更改一下代码:

            $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                ->setReplyTo($post['email'])
                ->sendTransactional(
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), // change this
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                    null,
                    array('data' => $postObject)
                );

希望有帮助!

谢谢,

The place where this gets sent is in app/code/core/Mage/Contacts/controllers/IndexController.php at abouts line 100. It looks like the reply-to address for the emails is already set to the email address from the post, so if you're just looking to get easier replies, I'd suggest not fooling with it.

Another issue that you'll likely see is that sending email with a spoofed "from" address may cause your site to quickly become blacklisted from many email providers, which may affect the rest of your business.

That said, if you still want to do this, in that file change this code a bit:

            $mailTemplate->setDesignConfig(array('area' => 'frontend'))
                ->setReplyTo($post['email'])
                ->sendTransactional(
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE),
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), // change this
                    Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT),
                    null,
                    array('data' => $postObject)
                );

Hope that helps!

Thanks,
Joe

海未深 2024-11-17 12:40:38

Magento 联系表 - 一直收到我自己的电子邮件 是这个问题的新副本,乔的回答让我走上了正确的道路。在我对重复问题的回答中,我编写了一个自定义模块来覆盖 app/code/core/Mage/Contacts/controllers/IndexController.php 并最终将上面指示的行更改为 array ('name'=>$post['name'], 'email'=>$post['email']), 进行修复。

恕我直言,当我在核心中进行紧急的小修复时,这些修复必须保留到正确超载为止,我肯定会在每一行的末尾加上我姓名首字母两次的注释//CKCK hack to fix ___,然后你可以 grep 并通过 ssh shell 查看所有 mod: app/code/core$ grep -rn "CKCK" *

我还使用 github 进行版本控制,这也有帮助。

Magento Contact Form - been receiving email from myself is a newer duplicate of this question and Joe's answer got me on the right path. In my answer to the duplicate question, I wrote a custom module to override app/code/core/Mage/Contacts/controllers/IndexController.php and ended up changing the indicated line above to array('name'=>$post['name'], 'email'=>$post['email']), to make the fix.

IMHO, when I do urgent small fixes in the core that have to stay until properly overloaded, I'm sure to end each line with a comment with my initials twice //CKCK hack to fix ___ and then you can grep for this and see all of your mods via ssh shell: app/code/core$ grep -rn "CKCK" *

I'm also using github for version control, which helps, too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文