Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Email package bug
  • I'm just passing along a bug in the email package that messes up the way emails display content when using hidden HTML comments inside of the email code. I only noticed this because I started using MJML (https://mjml.io) to create some advanced emails as they use a lot of HTML comments for Outlook compatibility.

    After some digging, the error is in the fuel/packages/email/classes/email/driver.php file on line 217. I'm using the fuel/email package, version 1.8.1. That block of code checks if you want to remove HTML comments, and if it's set to true (which it is by default), then the comments are removed. However, this messes up my emails as I need to leave the HTML comments untouched. If I comment out this block of code, my emails look great.

    There is a config option (remove_html_comments) to disable this, however it just doesn't work because of the code on line 214 which is incorrect. That line of code always sets the $remove_html_comments variable to true no matter what because it checks the config variable using the empty() function, and defaults it to true if the config variable is empty (which includes false). So if I set that config option to false, that line of code sets it to true regardless.

    I have no way around this except to change the core code on line 214 so that it sets the variable accordingly. I'm sure others must have this issue as well, however it is not really noticeable unless you are doing in-depth emails with HTML comments.
  • Harro VertonHarro Verton
    Accepted Answer
    That is indeed a very odd line of code !

    $remove_html_comments = isset($this->config['remove_html_comments']) ? (bool) $this->config['remove_html_comments'] : true;

    would be a better one.

    I'll push a fix to 1.9/dev.
  • Hi Harro!
    Thanks for the code push.
    I updated to the latest 1.9/dev package for fuel/email, however there's a new bug present which prevents any SMTP email from being sent. In the file 
    /fuel/packages/email/classes/email/driver/smtp.php on line 161, there's a call to PHP's stream_socket_client() function. In this block of code, 5 parameters are being passed, with the 5th parameter being the context resource when it should be an integer flag. The context resource should be the 6th parameter.

    Can you update that code to use the default STREAM_CLIENT_CONNECT flag as the 5th parameter? I tested with this flag and it seems to work just fine.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion