aschroder / Magento-SMTP-Pro-Email-Extension

Full SMTP and Gmail/Google Apps Email support for Magento
aschroder.com
333 stars 209 forks source link

Self test doesn't set a subject line, always comes back false #166

Open andrewwise opened 8 years ago

andrewwise commented 8 years ago

Unless I'm being silly here the self test will always come back unsuccessful as it doesn't set a subject line before calling isValidForSend() so it will come back false and throw the following errors:

Could not find default template, or template not valid, or email communications disabled in Advanced > System settings. Please check that you have templates in place for your emails. These are in app/locale, or custom defined in System > Transaction Emails. Also check Advanced > System settings to ensure email communications are enabled.

Call is on line 185 for the test controller, can be resolved by adding a subject line in the code immediately above.

aschroder commented 8 years ago

I'm not sure about that - looking at the core code which the self test emulates for e.g in the Contact From controller: https://github.com/OpenMage/magento-mirror/blob/d409dff20e992e97546568974399c456958299f9/app/code/core/Mage/Contacts/controllers/IndexController.php#L98

It calls sendTransactional() which loads the template in much the same way the self test does: https://github.com/OpenMage/magento-mirror/blob/d409dff20e992e97546568974399c456958299f9/app/code/core/Mage/Core/Model/Email/Template.php#L484

Then send() is called where the isValidForSend() function call is made: https://github.com/OpenMage/magento-mirror/blob/d409dff20e992e97546568974399c456958299f9/app/code/core/Mage/Core/Model/Email/Template.php#L373

I think you'll find the subject comes from the template file variables that get loaded and not from a setSubject call directly? I'm happy to be wrong on that if you can show me an example or something?

Maybe check if your templates define a subject? They should be like the core templates like this one: https://github.com/OpenMage/magento-mirror/blob/d409dff20e992e97546568974399c456958299f9/app/locale/en_US/template/email/contact_form.html

On Tue, May 10, 2016 at 11:49 PM, Andrew Wise notifications@github.com wrote:

Unless I'm being silly here the self test will always come back unsuccessful as it doesn't set a subject line before calling isValidForSend() so it will come back false and throw the following errors:

Could not find default template, or template not valid, or email communications disabled in Advanced > System settings. Please check that you have templates in place for your emails. These are in app/locale, or custom defined in System > Transaction Emails. Also check Advanced > System settings to ensure email communications are enabled.

Call is on line 185 for the test controller, can be resolved by adding a subject line in the code immediately above.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/aschroder/Magento-SMTP-Pro-Email-Extension/issues/166

versedi commented 8 years ago

Hi,

I've reproduced this issue on a fresh instance - 1.9.2.4

_All contacts_form.html are having first line with subject defined _ - nothing's changed in the locale files since the installation.

The only way to pass the test is add a line here: https://github.com/aschroder/Magento-SMTP-Pro-Email-Extension/blob/master/app/code/local/Aschroder/SMTPPro/controllers/Smtp/TestController.php#L182

Add an assignment of the $sub to templateSubject property.

            $mailTemplate->setSenderName("Test Name");
            $mailTemplate->setSenderEmail("test@email.com");
            $mailTemplate->setTemplateSubject($sub); //added

The test is now running properly but this isn't the way Magento processes the email. Do you have any idea what could have caused that the templateSubject isn't set automatically while processing the template?

Edit: One important variable that I've forgot to mention - this is a testing environment setup on PHP 7.0.9.1 with Inchoo's patch applied but I'm not aware of any compatibility issues with email templating system ATM.