Welcome Guest, Not a member yet? Register   Sign In
HTML Email Message Not Working?
#1

[eluser]Corey Freeman[/eluser]
I dunno what's wrong with my code, but I can't get the HTML to render. For some reason it's sending the HTML view in plain text.

Code:
//Email the User
                        $data['username'] = $this->input->post('username');
                        $data['password'] = $this->input->post('password');
                        $username = $this->input->post('username');
                        $email = $this->input->post('email');
                        $password = $this->input->post('password');
                        $data['secret'] = md5($this->input->post('email'));
                        $this->load->library('email');
                        $this->email->from('[email protected]', 'CloudReve - Aspiration Sharing');
                        $this->email->to($email);
                        $this->email->subject('Please Activate Your CloudReve Account');
                        $this->email->message($this->load->view('emails/activate', $data, true));
                        $this->email->set_alt_message('Thank you for signing up to cloudreve.com. Before you can begin sharing your aspirations with others, you need to confirm your email address by visiting this web address: http://www.cloudreve.com/activate/'.md5($email).'');
                        $this->email->send();
                    //Log them in for the first time!
                        $this->db->where('username', $this->input->post('username'));
                        $query = $this->db->get('users');
                        foreach($query->result() as $row):
                        $id = $row->id;
                        endforeach;
                        $data = array(
                        'id' => $id,
                        'username' => $this->input->post('username'),
                        'is_logged_in' => true,
                        'account_active' => false
                        );
                        $this->session->set_userdata($data);

VIEW

Code:
<html>
<head>
<title>Activate Your CloudReve Account</title>
</head>
    <body style="width: 600px; margin: auto; padding: 50px; font-family: helvetica, verdana, arial, sans-serif; color: #4B5263; font-size: 12px;">
        <table style="background: #fff; padding: 10px; width: 100%; line-height: 1.5em;">
            <tbody>
            <tr>
            <td style="text-align: center;"><img src="http://cloudreve.s3.amazonaws.com/email_logo.jpg" alt="CloudReve" /></td>
            </tr>
            <tr style="width: 100%;">
            <td><h3 style="text-align: center; margin-top: 10px;">Please Confirm Your CloudReve Email Address</h3></td>
            </tr>
            <tr>
            <td>Welcome to <a href="http://www.cloudreve.com">CloudReve</a>, the goal and aspiration sharing social network. Before you begin sharing your aspirations with the world, please <a href="http://www.cloudreve.com/activate/&lt;?=$secret?&gt;">confirm your email address by clicking this link.</a></td>
            </tr>
            </tbody>
        </table>
    &lt;/body&gt;
&lt;/html&gt;
#2

[eluser]JHackamack[/eluser]
Have you made sure to include:
Code:
$config['mailtype'] = 'html';

$this->email->initialize($config);
#3

[eluser]Corey Freeman[/eluser]
Ah. It's all so clear now. I'm a moron...

Thanks. Smile
#4

[eluser]Zocee[/eluser]
I'm having a weird problem here please see the following link:

http://ellislab.com/forums/viewthread/163620/
#5

[eluser]ModernM[/eluser]
Many thanks, this helped me get my HTML email working. By the way, how did you get the secret URL to work. What I have is a email view like yours that send out an email, but I want to have a link to a file that is encrypted or somewhat hidde, so the user doesnt see the direct URL. Something like http://www.site.com/files/ASe123ASr12DASD . I am new to PHP but I am managing pretty well, any help in the right direction would help.

Thanks
#6

[eluser]Samus[/eluser]
[quote author="ModernM" date="1337999579"]Many thanks, this helped me get my HTML email working. By the way, how did you get the secret URL to work. What I have is a email view like yours that send out an email, but I want to have a link to a file that is encrypted or somewhat hidde, so the user doesnt see the direct URL. Something like http://www.site.com/files/ASe123ASr12DASD . I am new to PHP but I am managing pretty well, any help in the right direction would help.

Thanks[/quote]
Create a random string, any method you want.

Store that string in your database.

Use an arguement in your controller method that will accept that random string.

Within your controller method, have a model which looks for that random string.

If it matches one, do something, else do something else.




Theme © iAndrew 2016 - Forum software by © MyBB