Welcome Guest, Not a member yet? Register   Sign In
Sending both HTML and Plain Text Email at the same time
#1

[eluser]robertrick[/eluser]
Hi all. I am having trouble sending a single email message using the email class.
here's the issue.
I want to send one email with both HTML and Plain Text in the same email so that
if the person receiving the email can only view plain text they see the part that is
the plain text. and vice versa with the HTML.

and suggestions???
#2

[eluser]PauloBr[/eluser]
Your doubt is how do you do this?

The email class of CI alredy have this function (automatic), if your mailtype configuration is 'html', the plain text mode is sent together.

BTW, if you have your own plain text e-mail, you can use:
Code:
$this->email->set_alt_message()

Take a look here: http://ellislab.com/codeigniter/user-gui...email.html

[]'s
#3

[eluser]batterj2[/eluser]
I'm having a similar problem and I may be missing something very trivial.

I've extended the Email class to provide the following function. It sends HTML emails fine but when I switch to the text version I either get nothing (in Thunderbird) or I get the raw HTML code.

Additionally it seems to be ignoring my pleas to not word wrap.

Code:
<?php
class MY_Email extends CI_Email
{
    function My_Email()
    {
        parent::CI_Email();        
    }

    function sendLoginDetails($user, $newPassword)
    {      
        parent::set_mailtype('html');
        parent::set_wordwrap(false);
        $CI =& get_instance();        
        $CI->load->helper('url');
        parent::from('example@example', 'Example');
        parent::to($user->email);
        parent::subject('Login Details');
        $message = '<html><head></head><body>';        
        $message = $message . '<p>Dear ' . $user->userName . ',</p>';
        $message = $message . '<p>Your login details are as follows:</p>';
        $message = $message . '<p><b>Username:</b> ' . $user->userName . '</p>';
        $message = $message . '<p><b>New Password:</b> ' . $newPassword . '</p>';
        $message = $message . '&lt;/body&gt;&lt;/html>';
        parent::message($message);        
        return parent::send();
    }
}
?&gt;

Usage:

Code:
$this->load->library('email');            
            if($this->email->sendLoginDetails($user, $newPassword))
            {
                ...

I'm using CI 1.7.1 - any help would be appreciated.




Theme © iAndrew 2016 - Forum software by © MyBB