Share wishlist email not being sent
-
28-12-2020 - |
Pregunta
Emails are being sent correctly (subsription, registration, etc...), but the share wishlist email is not being sent.
Email is not present in admin panel system/tools/SMTPPro - Email Log
.
Where I should begin to look to find what's not working? Which are the best steps to find the origin of the problem?
If I go to magento_path/app/design/frontend/theme/template/wishlist/sharing.phtml
I see that the share wishlist button is in a form, and the action form is <form action="<?php echo $this->getSendUrl() ?>" id="form-validate" method="post">
.
So I look into magento_path/app/code/core/Mage/wishlist/Block/Customer/Sharing.php
where getSendUrl() method is. And I place a log in this method:
Mage::log($this->getUrl('*/*/send'), Zend_Log::INFO, 'email_send.log', true);
The log in the file after trying to send the share email is:
2018-01-29T09:16:02+00:00 INFO (6): https://myweb.com/en/wishlist/index/send/
Once I see this I look into the wishlist index controller, the sendAction. And I place some logs there:
$emails = explode(',', $this->getRequest()->getPost('emails'));
Mage::log($emails, Zend_Log::INFO, 'email_send.log', true);
$message = nl2br(htmlspecialchars((string) $this->getRequest()->getPost('message')));
Mage::log($message, Zend_Log::INFO, 'email_send.log', true);
the $emails var is:
2018-01-29T09:28:47+00:00 INFO (6): Array
(
[0] => pim@youremail.cf
)
That is the email in entered
and the $message var is:
2018-01-29T09:28:47+00:00 INFO (6):
<div style="border:1px solid #E0E0E0; padding:15px; background:#F9F9F9;">
<table cellspacing="0" cellpadding="0" border="0" width="650">
<tr>
<td width="32%">
<p align="center" style="font-size:12px;"><a href="https://myweb.com/en/foo-sunset-eclipse.html"><img src="https://myweb.com/media/catalog/product/cache/1/small_image/135x/9df78eab3352/F/o/foo-sunset-eclipse.jpg" style="border:1px solid #ccc;" width="135" height="135" alt="" /></a></p>
<p align="center" style="font-size:12px;"><a href="https://myweb.com/en/foo-sunset-eclipse.html" style="color:#203548;"><strong>foo sunset eclipse/ natural</strong></a></p>
<p align="center" style="font-size:12px;"><a href="https://myweb.com/en/foo-sunset-eclipse.html" style="color:#1E7EC8;">Product view</a> <small>
|</small> <a href="https://myweb.com/en/checkout/cart/add/uenc/aHR0cHb3oyLmJlbm29tLdpc2hsaXNQv/product/1210/form_key/vtdo2iaN/nocookie/1/" style="color:#1E7EC8;"><strong>Add to Cart</strong></a> </p></td>
<td width="2%"></td>
</table>
</div>
that is the email template I'm trying to send.
Edit: Solution
I find the wishlist email sending code from the wishlist indexcontroller commented. I uncomment it and now emails are sent:
//this code was commented. So it prevented wishlist emails from being sent
foreach ($emails as $email) {
$emailModel->sendTransactional(
Mage::getStoreConfig('wishlist/email/email_template'),
Mage::getStoreConfig('wishlist/email/email_identity'),
$email,
null,
array(
'customer' => $customer,
'salable' => $wishlist->isSalable() ? 'yes' : '',
'items' => $wishlistBlock,
'addAllLink' => Mage::getUrl('*/shared/allcart', array('code' => $sharingCode)),
'viewOnSiteLink' => Mage::getUrl('*/shared/index', array('code' => $sharingCode)),
'message' => $message
)
);
}
Solución
I find the wishlist email sending code from the wishlist indexcontroller commented. I uncomment it and now emails are sent:
magento_path/app/code/core/Mage/Wishlist/controllers/indexController.php look for sendAction() method.
//this code was commented. So it prevented wishlist emails from being sent
foreach ($emails as $email) {
$emailModel->sendTransactional(
Mage::getStoreConfig('wishlist/email/email_template'),
Mage::getStoreConfig('wishlist/email/email_identity'),
$email,
null,
array(
'customer' => $customer,
'salable' => $wishlist->isSalable() ? 'yes' : '',
'items' => $wishlistBlock,
'addAllLink' => Mage::getUrl('*/shared/allcart', array('code' => $sharingCode)),
'viewOnSiteLink' => Mage::getUrl('*/shared/index', array('code' => $sharingCode)),
'message' => $message
)
);
}
I know that code/core code should never be edited, it must be overwritten instead.