codeigniter - Email library not sending the correct link -
i have following code:
$link = "www.domain.com/profile/forgot_password?user=".$username . "&key=".$key; $this->email->message('you requested reset password. follow link. <a href="'.$link.'"> ' . $link . "</a>. thank you,system support.");
all trying here create friendly message user when wish reset password. supposed be:
you requested reset password. click here so!
on click here word should have link in href go reset page. not working above code seems escaping html showing below in message sent. should interpret html tags not send them.
<a href='hdkjahskjdaskhdsjkahd'> djadjalksjdklasjdkajsd</a>
ensure have set appropriate email preferences send email in html format, particularly mailtype
preference:
//you can add more email preferences here $config['mailtype'] = html; $this->email->initialize($config); $link = "www.domain.com/profile/forgot_password?user=".$username . "&key=".$key; $this->email->message('you requested reset password. follow link. <a href="'.$link.'"> ' . $link . "</a>. thank you,system support.");
if prefer, can store email preferences in config file:
simply create new file called
email.php
, add$config
array in file. save file @config/email.php
, used automatically.
codeigniter's user guide specifies that:
if send html email must send complete web page.
so, means including of relevant tags use create webpage (<html>
, <body>
etc.). in order make easier manage, can store email template in view file, example:
application/views/email_templates/password_reset.php
this file can include relevant html send email, example:
//other appropriate html tags... <p>you requested reset password. follow link. <a href="<?php echo $link; ?>"><?php echo $link; ?></a>. thank you, system support.</p> //other appropriate html tags...
you can pass link view, , send view email:
$data['link'] = "www.domain.com/profile/forgot_password?user=".$username . "&key=".$key; $email_message = $this->load->view('email_templates/password_reset', $data, true); $this->email->message($email_message);
(i haven't included of required email functions to()
, send()
etc. these should easy enough work out.)
Comments
Post a Comment