Magento - 如何格式化“存储电子邮件地址”中的电子邮件地址?

时间:2012-06-01 02:40:28

标签: email magento formatting magento-1.5

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

Magento 1.5有可能吗?如果我尝试将格式放在字段本身,我会收到一条错误消息。

enter image description here

3 个答案:

答案 0 :(得分:1)

这就是发件人姓名字段的作用。这就是我的设置看起来和Thunderbird中的样子(我的webmail客户端同样也是这样):

image

答案 1 :(得分: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()函数。我之前在this question's answer中介绍了重写课程。然后,在这个新的重写类中,您可以使用PHPmailer,调用shell邮件命令,或者您可能知道允许此行为的任何PHP库。

祝你好运。

答案 2 :(得分:0)

我不确定它是否可行。在magento里面是Zend_Validate,它验证这样的电子邮件地址。我不这么认为像'Foo Bar'这样的电子邮件是有效的。但我认为客户电子邮件客户端的显示取决于客户端,不是吗?