CodeIgniter Forums

Full Version: sending html formatted email?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]anna16[/eluser]
Hi guys

Sorry about this very noob question.
I want to send a HTML formatted email.
I used these codes below but it doesn't work.
Code:
function send_activate_email($data)
  {
    $this->load->library('email');
  
    $this->email->from('[email protected]', 'Admin');
    $this->email->to($data['email']);

    $this->email->subject('Activate your account');
    $this->email->message("&lt;html&gt;&lt;head>&lt;/head&gt;&lt;body>Please click the link below to activate your account at samplesite.com<br><a href='coder9.com'>click here</a>&lt;/body&gt;&lt;/html>");    

    
    $this->email->send();    
  }

Where did i made wrong?

Thanks in advanced

El Forum

[eluser]eoinmcg[/eluser]
as per the wonderfully helpful userguide:

Code:
$config = array(
'type' => 'html'
);

$this->load->library('email');
$this->email->initialize($config);

El Forum

[eluser]anna16[/eluser]
Mmmm... I tried it but it did not work?

Here are the codes,
Code:
function send_activate_email($data)
  {
    $config = array(
    'type' => 'html'
    );
    
    $this->load->library('email');
    $this->email->initialize($config);    
  
    $this->email->from('[email protected]', 'Admin');
    $this->email->to($data['email']);

    $this->email->subject('Activate your account');
    $this->email->message("Please click the link below to activate your account at samplesite.com<br><a href='coder9.com'>click here</a>");    

    
    $this->email->send();    
  }


I wonder why?

El Forum

[eluser]eoinmcg[/eluser]
i really suggest you read the user guide:
http://ellislab.com/codeigniter/user-gui...email.html
Quote:If you send HTML email you must send it as a complete web page. Make sure you don't have any relative links or relative image paths otherwise they will not work.

if your email is still not sending you probably need to do some more digging. for example, do you have a mailserver installed otherwise you will not be able to send.