简体   繁体   中英

change sender email address of share wishlist mail in magento

i want to change the sender email address of the share wishlist email a customer send when share his wishlist with a friend, i'm trying to put the custmer email as the sender address, and the customer name as the from name, thought it could be done in the admin, you just can change it to another one, but i want the customer email, need some help here

thanks

I would not do it that way. Instead I would set the from address to be that of my web store and set the Reply-To header to be that of the recipients friend. Spoofing from addresses like that can land your email in spam traps.

After browsing the code a bit, it would seem that this email is send from

app/code/core/Mage/Wishlist/controllers/IndexController.php

So you need to overwrite this controller. I have never done such a thing, but it is doable. There is a topic here and if you google 'magento override controller' you'll also find a lot off info.

After that you must re-implement (meaning copy and edit) the method sendAction() . In it is a call

$emailModel->sendTransactional();

I also think you should leave the sender address to that of the store, because setting it to another address might mark the message as spam. But if you want to do it just change the second parameter of this call to an array with keys 'name' and 'email' and the desired values.

But I strongly advise to set the Reply-To header too. That is possible because this model uses a Zend_Mail object to do the dirty work and treats this object as a singleton. Meaning that if you create it as first and configure it, the next mail will be sent with this configuration. In code, change

foreach($emails as $email) {
    $emailModel->sendTransactional(
        Mage::getStoreConfig('wishlist/email/email_template'),
//snip

to

foreach($emails as $email) {
    $mail = $emailModel->getMail();
    $mail->setReplyTo($customer->getEmail());
    $emailModel->sendTransactional(
        Mage::getStoreConfig('wishlist/email/email_template'),
//snip

Success

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM