![](/img/trans.png)
[英]Sending email with gmail smtp with codeigniter email library
[英]How to add Gmail action buttons to codeigniter's email library?
我嘗試在從Codeigniter的電子郵件庫發送電子郵件時嵌入gmail 操作按鈕 。 我的郵件看起來像這樣-
$this->email->from('mail@mysite.com', 'MyName');
$this->email->to('user@yoursite.com');
$this->email->set_mailtype("html");
$this->email->subject('Testing action');
$msg = '<html>
<body>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"action": {
"@type": "ViewAction",
"url": "https://watch-movies.com/watch?movieId=abc123"
},
"description": "Watch the Avengers movie online"
}
</script>
<div>EMAIL CONTENT GOES HERE</div>
</body>
</html>';
$this->email->message($message);
之后,我要發送郵件。 它僅發送<div>EMAIL CONTENT GOES HERE</div>
部分。 沒有生成任何操作按鈕。 我什至嘗試使用Google開發人員頁面中提供的微數據。 沒用。 知道這里有什么問題嗎?
首先,似乎您使用的是錯誤的變量$message
而不是$msg
。
除此之外,我認為確定者正在轉義您的代碼。 查看_prep_quoted_printable
函數。
我建議您使用微數據方法: https : //developers.google.com/gmail/actions/reference/formats/microdata
從示例:
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://watch-movies.com/watch?movieId=abc123"/>
</div>
<meta itemprop="description" content="Watch the 'Avengers' movie online"/>
</div>
另外,別忘了您必須向Google注冊您的操作: http : //developers.google.com/gmail/actions/registering-with-google
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.