【问题标题】:how to add link in sendgrid message using html如何使用html在sendgrid消息中添加链接
【发布时间】:2016-08-02 07:41:01
【问题描述】:

我想在 sendgrid 中使用电子邮件发送链接

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

但它只是发送纯文本而不是像下面的消息那样呈现链接

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();
}

【问题讨论】:

标签: php sendgrid codeigniter-3


【解决方案1】:

您需要在电子邮件库中传递配置并且需要将电子邮件类型分配为html

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

【讨论】:

  • 后来我想通了。不过感谢您的宝贵时间
【解决方案2】:

您可以使用 PHP 函数 preg_replace。使用正则表达式检测链接并替换为相同的链接,但使用&lt;a&gt;。

更多信息:http://php.net/manual/en/function.preg-replace.php 这也应该有所帮助:Replace URLs in text with HTML links

【讨论】:

  • sendgrid 邮件 api 没有显示。
猜你喜欢
  • 2022-01-22
  • 2010-10-23
  • 1970-01-01
  • 2010-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多