Posted on

New SMTP Pro Magento Email extension released

I’ve had a chance to make a couple of improvements to my SMTP Pro email extension for Magento. Both changes are not exactly life altering, one adds extra error detection to the self-test, and the other fixes a header problem with the self-test (reported by Phil). More details follow about the changes, if you want to get the extension, download SMTP Pro on Magento Connect. (Updated: finally on Magento Connect!)

I now send a real live contact form message as part of the testing – and ensure that when the email sends, my extension code is actually being called. I’ve had a lot of people reporting problems with emails not sending lately, only to find it’s because some other extension is interfering with my email sending. This tweak to the self test will help identify those issues.

This is implemented as a static variable on the self test controller, that is set before sending the test email and then altered by the email observer (if it is called as expected):

// Now we test that the actual core overrides are occuring as expected.
// We trigger the password forgot email, as though a user had done so.
 
self::$CONTACTFORM_SENT = false;
$this->_sendTestContactFormEmail();
 
// If everything worked as expected, the observer will have set this value to true.
if (self::$CONTACTFORM_SENT) {
	$msg = $msg . "<br/> Contact Form test email used SMTPPro to send correctly.";
} else {
	$success = false;
	$msg = $msg . "<br/> Contact Form test email did not use SMTPPro to send.";
}

and the code in the observer that alters this variable:

// For the self test, if we're sending the contact form notify the self test class
if($event->getTemplate() == "contacts_email_email_template") {
        include_once "app/code/community/Aschroder/SMTPPro/controllers/IndexController.php";
        Aschroder_SMTPPro_IndexController::$CONTACTFORM_SENT = true;
}

The other change was trivial, adding a ->setFrom() call when sending the test email. Thanks to Phil for pointing that out.

Lastly, Eric requested a useful feature which I will add, but I haven’t had time to put that in to this release, next time!

Let me know any feedback you have on the changes, or if you’re having trouble sending emails in Magento – feedback welcome.

77 thoughts on “New SMTP Pro Magento Email extension released

  1. Hi Ashley !

    First – great extension (as far as I got).

    The problem i have is, that the self-test works great, but anything else is just not sent. Even without your extension it does not send mails to the admin (but to the client !). I installed your extension in hope it would solve this issue.
    So i wanted to ask, when you say that your extension sends a real live contact form message as part of the testing, does it do it just as a visitor would send a mail through the contact form ?

    Maybe you have some hints you could share ? I would greatly appreciate it !

    Marc-André

  2. Thanks Ashley! Yes, any other email or template add-ons threaten to over-ride your template.php over-ride and render certain functions null, usually causing Magento to default back to it’s standard files.

    It’s refreshing to see a developer so responsive to a free application!

    Great work 🙂

    phil

  3. My test executes the same code that the Contact Form does on the server side, so it doesn’t simulate the form POST, but everything else – it shouldn’t be the POST itself that is causing trouble in any case.

    Are you sending with the same email address that you are trying to receive with? if so, try setting up a disposable gmail account to test with?

  4. Thanks Phil, I hope it helps. I just checked out your store btw, cool concept, hope it goes well.

  5. I tried everything that came to my mind, changing all emails to different addresses (gmail, ext. domain, etc.).

    Well, now i suppose that there must be somewhere a conflict with another module, but no other i have installed should override the mail part.

    I saw that your selftest is using the right translation file (french in my case), at least i do not need to search at the translation level.

    Do you have an advice how to proceed to figure out when or when not a module is working ? I wrote already some of my own, but i always have the impression, there not loaded.

    Thank you very much, Ashley !

  6. @Marc-Andre – Here’s a tip, go into the app/etc/modules directory and try disabling all the extensions you don’t need (by changing true to false in each xml file). Then run the self test between re-enabling each one. Hopefully you’ll find out that way which one is causing the problem. The enable/disable in the Magento admin is not actually a proper disable in the sense of the whole module, just that modules block output. Let me know how you go. Also – are you using the latest version, that does the contact form test?

  7. Yes, the latest version of your module, and the selftest is always working, just the contact-form itself is not working at all.

    But i will try your suggested approach and disable the modules in the XML files directly to see if something changes.

  8. Well, the last try with disabling the modules was without result. The only emails i got came from your module.

  9. Ok, i stumbled upon this “hideit fix”, added the input into the form and commented the validation out in the controller, et it works !

    But now i got a error with your module, that it can’t find the index controller… X(

  10. Great Magento extension, good work!

    However… When sending newsletters to subscribers, it takes very long time to send each e-mail. Approximately 10 emails per minute. I am not sure wethere it has something to do with my server configuration or magento configuration… Any suggestions? I just updated to the latest version, but same thing happened with previous version also.

    Thank you!
    Janno

  11. I thought that was normal, to stop Magento causing your SMTP servers to be labeled as spam. It might be configurable?

  12. Hello Ashley:

    This is a great extensions, and I am using it in a production ecommerce website.

    It works fine in the last 2 month, and then suddenly break. Can not send out any emails at all. I have changed nothing (install new extensions, upgrade magento, etc) except upload new products, and I checked with my hosing company, they said they did not change anything either.

    Here is detailed information when I run the Self Test:

    ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using Google Apps/Gmail configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address sales@curtains4australia.com:
    Unable to send test email. Exception message was: Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in /home/curtains/public_html/lib/Zend/Mail/Protocol/Smtp.php on line 206…
    Please check and double check your username and password.
    Contact Form test email did not use SMTPPro to send.
    Testing failed, please review the reported problems and if you need further help visit ASchroder.com to contact me.

    I find out someone else has met the same problem when trying to find help on your website, and I have tried their method: reinstall it. I even installed the latest 1.3.1 version. Got no luck. I also checked the usename and password, all are correct.

    I am using Magento 1.4.0.1, and OpenSSL is enabled (because the administration of my website is accessed through SSL).

    I am really appreciate for any help,

  13. Hi, Michael
    Glad to hear you like my extension! That error is typical of a PHP runtime that is missing openssl support. You need to ask your hosting provider to triple-check they have SSL installed for your PHP. I’m not 100% sure that accessing Apache through https implies your PHP has openSSL support installed. Please contact your web host and confirm.

    Just send them this error message and the following link:

    Unable to send test email. Exception message was: Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in /home/curtains/public_html/lib/Zend/Mail/Protocol/Smtp.php on line 206…

    http://stackoverflow.com/questions/1094137/zend-mail-gmail-smtp

    If that is not enough info for them to resolve the issue, then I think it’s time for a better web host!

    Please let me know how you get on.

  14. Hello Ashley,

    Great extension, thanks!

    Did you test this version on Magento 1.4.1.0 already?
    I used your version 1.1.1 on Magento 1.4.0.1 successfully.

    Now I’m testing version 1.3.1 on Magento 1.4.1.0
    All settings are correct (very simple: smtp/localhost/25), when I run a self-test I receive 2 emails stating everything is correct.
    The self-test emails (and manual filled in contact form) are perfectly showing up in the mail log.
    However, despite everything seems correct, the self-test reports an error:

    ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using SMTP configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address ….
    Test email was sent successfully.
    Contact Form test email did not use SMTPPro to send.
    Testing failed, please review the reported problems and if you need further help visit ASchroder.com to contact me.

    Any ideas?

    Thanks.

  15. Hi Hendrikus, Thanks for the kind words. I haven’t tested on Magento 1.4.1.0 yet – so you’re pioneering, but I’d very much appreciate your help!

    That failure is being caused by the new test I added recently. The test sends a contact form message and then ensures that my extension was used to send it (and not something else). Two things are possible with the failure message you are receiving; 1) the test is actually not testing properly, so that everything is fine and it is a false negative 2) The extension is actually not being called, which would indicate another extension is clashing, or the 1.4.1 version changed in such a way that my extension no longer overrides the core functionality as intended.

    To diagnose further – do emails send properly, say a password reset or a new order email for example?

  16. Hi Ashley,

    I did some testing: made orders, made account, password reset. All actions correctly sent emails to my email boxes and all emails show in the email log.
    The extension is called and functioning properly, so I think the self-test is giving a false negative?

    Thanks.

  17. Thanks for reporting back – glad to hear it’s working. I agree it’s false positive. I’ll keep an eye out for what might be causing that.

  18. Hello Ashley. I needed a custom contact page so I created a CMS page and included the contact form using this code:

    {{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}

    If I navigate directly to the contact form, the form sends properly. BUT it will not send from my new CMS with with the block code to include the contact form. Is there something I should know to create a custom contact page like what I want to do?

  19. Hi, does that work? I haven’t tried it, but if you have that page live and viewable, send me a link and I’ll take a look.

  20. Hi Ashley,

    First and foremost, amazing extension!

    But I also seem to have some problems with it… The test function on 1.4.1 says indeed “Contact Form test email did not use SMTPPro to send.” though in the System.log file it says:
    2010-06-26T12:57:13+00:00 DEBUG (7): Running SMTP Pro Self Test
    2010-06-26T12:57:13+00:00 DEBUG (7): Development mode: disabled
    2010-06-26T12:57:13+00:00 DEBUG (7): Raw connection test….
    2010-06-26T12:57:13+00:00 DEBUG (7): Complete
    2010-06-26T12:57:13+00:00 DEBUG (7): Actual email sending test….
    2010-06-26T12:57:13+00:00 DEBUG (7): Preparing the Google Apps/Gmail Email transport, email to send with is: website@******.com
    2010-06-26T12:57:13+00:00 DEBUG (7): Returning transport
    2010-06-26T12:57:14+00:00 DEBUG (7): Test email was sent successfully
    2010-06-26T12:57:14+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-06-26T12:57:14+00:00 DEBUG (7): Complete

    So it looks like everything is working, but nonetheless I don’t receive any emails. Neither through the contact form nor registration emails (when sending those it says: 2010-06-26T13:26:09+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template in the log).

    Any idea what could be causing this? I already tried disabling all extensions to no avail…

    All the best,

    Frederik

  21. Wow, great debug Frederik – that should be the template for all support requests! You’re right, that all does seem a little strange. There may be something in Magento 1.4.1 that breaks the self test, I haven’t upgraded any of my own stores yet, to know for sure.

    Ignoring the self test though, you’re saying the emails themselves still do not actually send, despite the logs indicating they will – the log event you pasted in – does it follow up with the log output of an actual send (i.e setting up the transport)?

  22. Hi Ashley,

    I have installed the your great extension and everything is working, but the content form gives the wrong message after sending. So the email is send correctly, but gives the message it was unable to send the email. The magento version is 1.4.0.1

    I hope you can help us.

    Best regards,

    Otto Smittenaar

  23. Hi, Otto – do you mean during self test, or when you actually use the contact form? Do you have other extensions running that would affect the contact form?

  24. Hi Ashley, You’re probably right. I have tested it with a clean Magento demo store and then everything works. I must first establish a new development environment, then I can test if it does work without any extensions.

  25. Any word on 1.4.1 compatibility? I am fed up with Magento’s email handling, but I want to make sure SMTP Pro works with the newest version of Magento before I install it.

  26. Hi, Matt – I don’t see why it _wouldn’t_ work but I’m not running any 1.4.1 production stores to give you a firm yay or nay – you could try it and let me know ? 🙂

  27. Hi Ashley, sorry I’m replying a little late. No, there is no other log output I’m afraid. It says the emails are sent and that’s it…

  28. I cant seem to get the any email to send from my site. I downloaded your wonderful extension got the test email to work great but still nothing sends from my site. I am a bit new to magento and I am wondering if there are some settings I need to change to turn on email in general? I would really appreciate the help.

    Thanks
    Jud

  29. Hi, Jud – can you let me know what output you get from the self test? Also try enabling logging in the developer section of the admin and then send me the log file contents after a self test, and some other email action say a contact form submit.

  30. Thank you so much for your quick response I am so impressed. My email test works every time and I get the email promptly from the test. However no other email is working throughout magento. I have tried every thing from a contact form to a lost password. None of the emails come back to me. I am not sure what I am doing wrong. HELP!!!

    Below are the logs you asked for and the results.

    ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using Google Apps/Gmail configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address jjenkins@rentinglife.com:
    Test email was sent successfully.
    Testing complete, if you are still experiencing difficulties please visit ASchroder.com to contact me.

    here is my log file.
    2010-07-13T22:59:49+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T16:09:38+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T16:09:39+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T17:25:44+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T17:26:08+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T17:28:57+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T17:35:20+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T17:37:35+00:00 DEBUG (7): SMTPPro is enabled, sending email in Aschroder_SMTPPro_Model_Email_Template
    2010-07-14T18:05:21+00:00 DEBUG (7): Running SMTP Pro Self Test
    2010-07-14T18:05:21+00:00 DEBUG (7): Development mode: disabled
    2010-07-14T18:05:21+00:00 DEBUG (7): Raw connection test….
    2010-07-14T18:05:21+00:00 DEBUG (7): Complete
    2010-07-14T18:05:21+00:00 DEBUG (7): Actual email sending test….
    2010-07-14T18:05:21+00:00 DEBUG (7): Preparing the Google Apps/Gmail Email transport, email to send with is: jjenkins@rentinglife.com
    2010-07-14T18:05:21+00:00 DEBUG (7): Returning transport
    2010-07-14T18:05:25+00:00 DEBUG (7): Test email was sent successfully
    2010-07-14T18:05:25+00:00 DEBUG (7): Complete

  31. I’m having the exact same problem as you Jud. Test e-mails are working (though the test itself says it failed in 1.4.1) fine (the e-mails arrive immediately), but e-mails sent by Magento or with the contact page don’t work at all…

  32. Hello Ashley.

    First of all: Thanks for your extension. It works like a charm in Magento 1.4.1.0.
    So for all you who hesitate to use this extension in 1.4.1.0: It’s working!

    Now, everything would be just fine if I left it there, but I messed up my test installation with multiple stores, so I restored an old database. (Dropping the magento scheme in mysql, and running the sql from the backup).
    The state of the database is before I installed the SMTP Pro extension, but the SMTP Pro files are left in place, so no change there.
    When I then again set up the SMTP Pro with the same settings as before (or any setting that I try), I get “The service is unavailable.” as the response when I run the self test.
    I don’t know too much about Magento, so I don’t know where to look for log files.
    I checked the smtp pro log table in the database, and it is blank (I have checked the log all emails checkbox).

    Just to check what could be wrong, I restored my “corrupt” database. That way my test stores doesn’t work, but I knew that the SMTP Pro worked. And after the restore of that database, I am again able to send the test mails.

    Going back again to my early state with working stores gives me the same error again: “The service is unavailable.” (When sending the test mail).

    So based on that I’d say that there is something that I have done wrong in the database. The question is: Can you please provide as many and detailed pointers as possible to solve this problem?

    Thanks.
    /Jonas (from Sweden)

  33. Hi, Frederik – two things to check 1) that your overall smtp setting is not disabled (it’s a built in magento setting) and 2) test the contact form template is not broken by creating a new template based on the old one under transactional emails and then assigning it in the configuration for the contact form. Let me know how you get on.

  34. Hi, Jonas – Thanks for contacting me, don’t take this the wrong way, but anytime I see the phrases; corrupt database, dropping the magento schema and I don’t know too much about Magento in one blog comment, I’m instantly worried. My #1 solution is to always put aside your problem install (i.e move magento to magento.old) and start over with a fresh install and DB. If you can get that working, then at least you have some solid ground to start from. If you are trying to fix things and you’re not sure whether it will ever actually work, then you’ll end up chasing your tail. That’s not really Magento advice, it’s just general computer advice, the same approach can be taken with wifi routers, and EJB’s. Sorry I can’t be of more tangible help on this one, but there are so many variables (things that could be wrong) it’s hard to know where to start.

  35. I’m having similar problems to Jud where the testing email works great and quick but no other emails send. No contact form, pw reset, order or new account emails. I’m also on 1.4.1. I guess this isn’t working for 1.4.1 yet…..has anyone had any luck with 1.4.1?

  36. Hi, Matt – check my reply to Frederik for some things to check for if the extension isn’t sending emails but the test is passing.

  37. Dear Ashley,

    You can remove my last comment, I was a bit too hasty trying out the things you said and did not notice that one of the other developers had disabled your extension. The problem was indeed the templates that were corrupted. Creating new ones solved everything.

    Thank you so much for helping out!

    All the best,

    Frederik

  38. The test fails at the SMTP from contact form but passes everything else. I’m using the standard magento contact us form and haven’t changed it in my template. I had this working perfectly with 1.3 but now I have switched hosts. I wonder if the host is blocking something.

  39. Hi Ashley,
    I test it in Magento1.401, Magento1.410 and Magento 1.411, It work fine in Magento1.401, the other failed , I get the flollowing infomation when Run Self Test, and when i sent emails to my customer, not any emails can be sent out. Could you help me, Thanks.
    ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using Google Apps/Gmail configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address crazyfashionshow@gmail.com:
    Test email was sent successfully.
    Contact Form test email did not use SMTPPro to send.
    Testing failed, please review the reported problems and if you need further help visit ASchroder.com to contact me.

  40. Hi, William thanks for helping with the testing! – I think there might be an issue in my self test reporting a failure when infact it is a success. Can you please send me via email, or paste back here, the log output during a self test, and also log output of a contact form submit and a password reset? Ideally for both the versions that work and don’t. With that info I’ll try to pin down what’s wrong and get you a patch turned around quickly.

  41. ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using Google Apps/Gmail configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address hello@example.com:
    Unable to send test email. Exception message was: Unable to connect via TLS…
    Please check and double check your username and password.
    Contact Form test email did not use SMTPPro to send.
    Testing failed, please review the reported problems and if you need further help visit ASchroder.com to contact me.

    Can you please help me out with this error message

  42. Looks like problem with TLS: Unable to connect via TLS… – check with your host?

  43. Dear Ashley,

    Maybe it is also a good idea for a future release to sort the email history from: most recent – oldest instead of oldest on top (like it is now).

    A small tweak to make life comfortable 🙂

    Keep up the good work,
    Erik

  44. Nice idea Erik, It’s on my list.

  45. Hi Ashley,

    Would just like to say thank you for writing such great software!

    I’m having difficulty with a module conflict. The Maison Du Logiciel’s Quotation Module seems to be conflicting. I was wondering what we can do to stop this? I’m getting the following error message:

    ———-
    ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using Google Apps/Gmail configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address sales@thec*************:
    Test email was sent successfully.
    Contact Form test email did not use SMTPPro to send.
    Testing failed, please review the reported problems and if you need further help visit ASchroder.com to contact me.
    ————

    I was wondering if you could please help?

  46. Hi,

    I’ve got it to work now. I had to change app/code/community/aschroder/SMTPPro/model/email/template.php
    class Aschroder_SMTPPro_Model_Email_Template extends Mage_Core_Model_Email_Template {

    TO:
    class Aschroder_SMTPPro_Model_Email_Template extends MDN_Purchase_Model_Core_Email_Template {

    —-
    But I now have another issue. It doesn’t seem to be sending attachments 🙁

    Thank again for a great module!

  47. I cannot get the google apps credentials to save in the admin, and
    I am getting the following error:
    ASchroder.com SMTP Pro Self-test results
    Testing outbound connectivity to Server:
    Using Google Apps/Gmail configuration options
    Connection to Host SMTP server successful.
    Sending test email to your contact form address joan@xxx.com:
    Unable to send test email. Exception message was: 334 UGFzc3dvcmQ6 …
    Please check and double check your username and password.
    Contact Form test email did not use SMTPPro to send.
    Testing failed, please review the reported problems and if you need further help visit ASchroder.com to contact me.

    Please advise…

  48. @David – The 334 error often means you have to log in to your gmail webmail and solve a captcha as you have got the wrong password too many times. That’s probably because the password is not being saved. A few people have had issues with values not saving, but I’m not sure why that would be. If you email me some details I’ll take a quick look.

    @Andrew – welcome to Magento extension clashing hell – you solved one clash with that parent class swapping trick/hack – but if you didn’t carefully check the actual functionality being changed – it may have introduced errors. the attachment thing may be another clash, or it may be a result of the first change you made. First step is to disable (disable them in app/etc/modules) or delete extensions and see if you can send email then.

  49. Hi Ashley,

    I was so so happy to find this extension (spent hours reading all kind of doughy solutions to send email from my local PC) when this happened. I´m new on Magento, but I normally work my way around reading about it and I assisted to this last summer webminars… But still… I can´t figure out whats the story with this.
    Trying to install this on my local version of Magento 1.4.1.1,
    It seems like there is something wrong with the extension key provided or I just dnt know how to do it..Need a bit of guidance here…

    This is what the Console Screen says after submitting the extension key on the magento connect manager:

    “Failed to download magento-community/ASchroder_SMTPPro within preferred state “stable”, latest release is version 1.3.4, stability “beta”, use “channel://connect.magentocommerce.com/community/ASchroder_SMTPPro-1.3.4” to install
    Cannot initialize ‘channel://connect.magentocommerce.com/community/ASchroder_SMTPPro’, invalid or missing package file
    Install Errors
    Package “channel://connect.magentocommerce.com/community/ASchroder_SMTPPro” is not valid
    PEAR ERROR: install failed”

    Deeply thank you. Even just for building this app 🙂

    Tino

  50. @Tino – From within the Magento Connect Manager on your site, go to the Settings tab, and changed Preferred State to Beta.

Comments are closed.