CodeIgniter Forums

Full Version: display the email as a web page in receivers inbox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]max123[/eluser]
I have a send email module.It works. There is a separate web page to display the email message.But the problem is, email is displayed as a text document in receiver’s inbox(with html tags displayed). I want to disply it as a web page. Values of php variables also don’t display. What might be the reson

Thanx

El Forum

[eluser]theprodigy[/eluser]
can you show the code you are using? It's alot easier to debug that way.

If you are using CodeIgniters Email class to do the emailing, you may also want to checkout how to set the Email Preferences in the user_guide.
(Particularly, the mailtype setting ;-) ).

El Forum

[eluser]max123[/eluser]
This is my function. Emails are working. Only thing is i want to send a web page as an email. Now when the email receives, all the <html> tags are displayed. This function is inside the library folder

Code:
public function send_to_friend($data)
    {        
            $message=$this->ci->load->view('vacancy_send_to_friend_text','',TRUE);
            $this->ci->email->clear();
            $this->ci->email->set_newline("\r\n");
            $this->ci->email->from('[email protected]', 'name');
            $this->ci->email->to($data['send_to']);
            $this->ci->email->subject('This is the subject');
            $this->ci->email->message($message);
            return $this->ci->email->send();
    }

El Forum

[eluser]Maglok[/eluser]
Set the mailtype to html and set some more options like this:

Code:
$this->load->library('email');
                $config['mailtype'] = 'html';
                $config['protocol'] = 'sendmail';
                $config['mailpath'] = '/usr/sbin/sendmail';
                $config['charset'] = 'iso-8859-1';
                $this->email->initialize($config);

Recently made one myself. Be aware though that most email clients will block images and links till the user allows it or puts the adress on trusted.

Also, and this I don't get, gmail has a lot more spacing then other clients. I guess you could fix it by including a stylesheet.

El Forum

[eluser]max123[/eluser]
I change myemail config file also. Still it doesn't work. This is my email config file
Code:
<?php  //if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    $config['protocol'] = 'sendmail';  
    $config['smtp_host']    = 'mail.something.com';
    $config['smtp_port']    = '21';
    $config['smtp_timeout'] = '7';
    $config['smtp_user']    = '[email protected]';
    $config['smtp_pass']    = '[email protected]';
    $config['charset'] = 'iso-8859-1';
    $config['newline']    = "\r\n";
    $config['mailtype'] = 'html'; // or text
    $config['validation'] = TRUE; // bool whether to validate email or not
    $config['mailpath'] = '/usr/sbin/sendmail';

El Forum

[eluser]Maglok[/eluser]
You initialized it right?

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

Also it has to be a proper full webpage, so <html> tags and everything.

El Forum

[eluser]max123[/eluser]
All the email configurations are in the email config file. There for do I need to insert $this->email->initialize($config); code. All the <html> and other tags are there in the message page.

El Forum

[eluser]Maglok[/eluser]
I don't know of a basic email config. If you cooked it up it still needs loading cause it is not part of the CI functionality. Try to initialize see what happens.