0

I want to send a link using email in sendgrid

$html =  'click on this   <a href="' . current_url . site_url("/users/verfication?code=" . $code)  . '">link</a>  to verify your account';

but it just send plain text instead of rendering link like below message

click on this   <a href="//users/verfication code=283add227e43e2674980ce9bbcd34833">link</a> 
  to verify your account


$CI->email->to($to);
        $CI->email->subject($sub);
        $CI->email->message($html);
        $CI->email->send();
}
owais
  • 4,752
  • 5
  • 31
  • 41
  • Did you look at the Sendgrid documentation? You need to format the mail to be HTML format, and there are a number of ways to do this (Swiftmail, Sendgrid API, etc.). See: https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/php.html and other docs... – ldg Aug 02 '16 at 07:47
  • @ldg it's php api. I am using codeigniter here https://sendgrid.com/docs/Integrate/Frameworks/codeigniter.html – owais Aug 02 '16 at 07:49
  • take a look : http://stackoverflow.com/questions/28723653/sendgrid-set-headers-content-type – Goku Aug 02 '16 at 07:53
  • @DOZ I am not asking about changing header. i want to know how to render content. – owais Aug 02 '16 at 07:55
  • I know, but I think you issue comes from here – Goku Aug 02 '16 at 07:57
  • @bawag Can you please take a look at the following question: https://stackoverflow.com/q/66760554/9409877 – HKS Mar 23 '21 at 17:23

2 Answers2

0

You can use the PHP function preg_replace. Use a regular expression to detect a link and replace by the same link but with a <a>.

More info : http://php.net/manual/en/function.preg-replace.php And this should also help : Replace URLs in text with HTML links

Community
  • 1
  • 1
tomfl
  • 707
  • 1
  • 11
  • 29
0

You need to pass config in email library and need to assign email type as html

$config = Array(
    'mailtype' => 'html',
    ...etc...
);
$this->load->library('email', $config);