Welcome Guest, Not a member yet? Register   Sign In
[CI 1.7 rev 1572+] Email Class - html email problems
#11

[eluser]vigna[/eluser]
Hi a&w,
Thank you very much for the post. I too had similar problems with the email html text.
And once I replaced the changed-email-class of yours, it worked like a charm.

Thanks once again!
#12

[eluser]wortell[/eluser]
[quote author="a&w" date="1227137492"]Here's modified version based on above comments.[/quote]


a&w - not even sure if you still frequent this thread... but!
you rawk! no, seriously...

MY BIGGER concern - as has been since i started using CI for the past 4 weeks, understanding, building, etc... is that when there is a SOLID solution like this...

***WHY OH WHY!!!!***
doesn't it get looked at, integrated with, etc, into the latest releases of CI.

I spent **TOO** long dealing with this, for the past few days... as it relates to using html email and i read the wiki, read numerous resources, etc.. etc... and yet the header/alt boundary section you put into it CLEARLY fixed it all.

FYI - I'm using (for all who want to confirm):
CI 2.0
HVMC - with MS/E 5.3+
Ion_Auth (which is where i first ran into the html mail issue in part. - not the auth library itself)
php 5.3.3
os - windows vista
xampp

(yep, probably more than most want to know, but for me it helps and hopefully you'll be helped too!)

my implementation of it was to (since using MS/Extensions + CI 2.0) override and add to the CI_Email by creating a library file:

for hoping to help with this thread... i'll post in the next post what my MY_Email.php library file looks like.

I did this so as to keep the 'core' the core.
#13

[eluser]wortell[/eluser]
Code:
/***
*
*  Created Library Extension of CI_Email using MY_Email
*  based on a&w's work here:
*  http://ellislab.com/forums/viewthread/97440/
*
**/
class MY_Email extends CI_Email {

    // --------------------------------------------------------------------
    // below variable introduced from a&w's post taken from:
    // http://ellislab.com/forums/viewthread/97440/
    // --------------------------------------------------------------------

    var $_alt_boundary = "";    // used in hack/extension

    function MY_Email($config = array( )) {
        parent::CI_Email();
    }


    // --------------------------------------------------------------------
    // below functions added from a&w's post taken from:
    // http://ellislab.com/forums/viewthread/97440/
    // --------------------------------------------------------------------

    //new method for maintainability/consistency, etc.
    function _get_content_type_header($type = 'html') {
        if ( $type == 'multi' ) {
            return "Content-Type: multipart/alternative; boundary=\"".$this->_alt_boundary."\"".$this->newline;
        }
        return "Content-Type: text/".$type."; charset=".$this->charset.$this->newline;
    }

    //new method for maintainability/consistency, etc.
    function _get_content_encoding_header($type = 'data') {
        if ( $type == 'quoted-printable' ) {
            return "Content-Transfer-Encoding: quoted-printable";
        }
        return "Content-Transfer-Encoding: ".$this->_get_encoding();
    }


        // --------------------------------------------------------------------
        // below override function taken from:
        // http://ellislab.com/forums/viewthread/97440/
        // --------------------------------------------------------------------

    /**
     * Build Final Body and attachments
     * (modified as per above)
     *
     * @access    private
     * @return    void
     */
    function _build_message() {
        
      // for sake of space/speed - see:
      // thread: http://ellislab.com/forums/viewthread/97440/
      // to get the _build_message() function and put it here...

    }

}
/***
*
*  so ends MY_Email extension of CI_Email
*  based on a&w's work here:
*  http://ellislab.com/forums/viewthread/97440/
*
**/
#14

[eluser]yacman[/eluser]
With php5.3, it has a built in quoted_printable_encode and _decode method.

You can overload this easily
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* CodeIgniter Email Class
*
* Permits email to be sent using Mail, Sendmail, or SMTP.
*
* @package  CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author  ExpressionEngine Dev Team
* @link  http://ellislab.com/codeigniter/user-guide/libraries/email.html
*/
class MY_Email extends CI_Email {

/**
  * Prep Quoted Printable
  *
  * Prepares string for Quoted-Printable Content-Transfer-Encoding
  * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
  *
  * Checks if quoted_printable_encode is a function and will use the built
  * in method in php 5.3, otherwise uses the current CI_Email version.
  *
  * @access protected
  * @param string
  * @param integer
  * @return string
  */
protected function _prep_quoted_printable($str, $charlim = '')
{
  if (function_exists("quoted_printable_encode")) {
   return quoted_printable_encode($str);
  } else {  
   return parent::_prep_quoted_printable($str,$charlim);
  }
}
}




Theme © iAndrew 2016 - Forum software by © MyBB