0

我要做的是像这样格式化电子邮件地址,Foo Bar <foo@bar.com>以便电子邮件客户端(包括基于 web 的 gmail)将发件人显示为“Foo Bar”而不仅仅是“foo”,因为这是电子邮件的前缀。

这在 Magento 1.5 中可行吗?如果我尝试将格式设置在字段本身中,我会收到一条错误消息。

在此处输入图像描述

4

3 回答 3

1

这就是发件人姓名字段的作用。这就是我的设置和 Thunderbird 中的设置(我的 webmail 客户端的格式也类似):

图片

于 2012-06-01T13:45:37.837 回答
0

您可以查看code/core/Mage/Core/Model/Email.php实际的邮件实现。您可能会注意到它使用Zend_Mail. 现在,这是问题所在:

For security reasons, Zend_Mail filters all header fields to prevent header 
injection with newline (\n) characters. Double quotation is changed to single 
quotation and angle brackets to square brackets in the name of sender and recipients. 
If the marks are in email address, the marks will be removed.

您可以做的是制作一个模块来重写当前类Mage_Core_Model_Email并覆盖send()函数。我之前在这个问题的答案中介绍了重写课程。然后,在这个重写的新类中,您可以使用 PHPmailer、调用 shell 邮件命令或任何您碰巧知道的允许这种行为的 PHP 库。

祝你好运。

于 2012-06-01T13:37:34.613 回答
0

我不确定它是否可以工作。在 magento 里面是一个 Zend_Validate,它对这些电子邮件地址进行验证。而且我不认为像“Foo Bar”这样的电子邮件是有效的。但我认为客户电子邮件客户端中的显示取决于客户端,不是吗?

于 2012-06-02T15:48:52.063 回答