Welcome Guest, Not a member yet? Register   Sign In
Sending Email with a message in HTML from a view?
#1

[eluser]markanderson993[/eluser]
Hello there, I was dabbling around last night in the Email class and tried sending myself an email. This is the code I used.

Code:
function _send_new_comment_email($author_id,$recipient_id)
    {
        $author_name = ucfirst($this->user_info_model->get_user_name($author_id));
        $recipient_name = ucfirst($this->user_info_model->get_user_name($recipient_id));
        $recipient_email = $this->user_info_model->get_user_email($recipient_id);
        $url = $_SERVER['HTTP_REFERER'];
        
        $message = '<b>'.$author_name.'</b>. has commented on your music!<br /><a href="'.$url.'">Click here to view your comment!</a>';
    
        $this->email->to("[email protected]");
        $this->email->from('[email protected]');
        $this->email->subject("$author_name has commented on your music");
        $this->email->message($message);
        $this->email->send();
    }

Now the problem was, when I recieved the email, everything including the html tags were printed out.. why? Do I have to do something special to account for this? And also, it would be a world of difference If I could simple assign the $message value the contents of a specially created View. Is this possible??

Any help is greatly appreciated!
Thanks!

- Pianoman993
#2

[eluser]pistolPete[/eluser]
You have to set the mailtype according to the user guide:
Code:
$config['mailtype'] = 'html';

Have a look at Returning views as data:
Quote:There is a third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser.
#3

[eluser]markanderson993[/eluser]
Neat it worked, thanks for the response.




Theme © iAndrew 2016 - Forum software by © MyBB