jyoseph
jyoseph

Reputation: 5455

Magento - How to format the email address in "Store Email Addresses"?

What I'm trying to do is format the email address like so Foo Bar <[email protected]> so email clients (including web based like gmail) will show the sender as "Foo Bar" and not just "foo" since that is the prefix on the email.

Is this possible in Magento 1.5? If I try to put the formatting in the field itself I get an error message.

enter image description here

Upvotes: 0

Views: 688

Answers (3)

Jaro
Jaro

Reputation: 3887

I'm not sure if it can work. In magento inside is a Zend_Validate which does validation of such email addresses. And I dont think so that email like 'Foo Bar ' is valid. But I think the display in customer's email client depend on client, no?

Upvotes: 0

Alex Jegtnes
Alex Jegtnes

Reputation: 184

That's what the Sender Name field does. This is what my setup looks like and what it looks like in Thunderbird (my webmail client formats it similarly, too):

image

Upvotes: 1

Seth Malaki
Seth Malaki

Reputation: 4486

You may look at code/core/Mage/Core/Model/Email.php for the actual mail implementation. You may notice it uses Zend_Mail. Now, here is the catch:

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.

What you can do though is to make a module to rewrite the current class Mage_Core_Model_Email and overwrite the send() function. I covered rewriting classes before in this question's answer. Then, in this new rewritten class, you could PHPmailer, invoke shell mail commands, or whatever PHP library you would happen to know that would allow this behaviour.

Best of luck.

Upvotes: 0

Related Questions