How to add link in subject of email (gmail)

萝らか妹 提交于 2019-12-03 05:53:24

问题


Is there a way to add link in subject of email? Following is the example of YouTube -

Here in my code I'm trying the following but still unsatisfactory result. The below code is sending the subject as it is with printing the whole anchor tag in the subject.

public function contact_us($data)
{
    $from = "from@example.com";
    $to = "to@example.com";
    $view = 'emails/contact_us';
    $subject = "Contact Us <a href='http://www.example.com'>Link</a>";
    $view_data = $data;

    $this->send($from,$to,$subject,$view,$view_data);
}

回答1:


I'm glad you asked! This is an awesome new feature and standard Google is supporting, part of the Schema.org initiative.

Copying their example here which allows customers to review something directly from the email! This block would be copied directly into your mail template.

<script type="application/ld+json">
{
  "@context":               "http://schema.org",
  "@type":                  "Restaurant",
  "name":                   "Google Cafe",
  "action": {
    "@type":                "ReviewAction",
    "review": {
      "@type":              "Review",
      "reviewRating": {
        "@type":            "Rating",
        "bestRating":       "5",
        "worstRating":      "1"
      }
    },
    "handler": {
      "@type":              "HttpActionHandler",
      "url":                "{{ review_url }}",
      "encoding": {
        "url":              "http://schema.org/Encoding/UrlEncoded"
      },
      "method":             "http://schema.org/HttpRequestMethod/POST",
      "requiredProperty": {
        "@type":            "Property",
        "name":             "review.reviewRating.ratingValue"
      },
      "optionalProperty": {
        "@type":            "Property",
        "name":             "review.reviewBody"
      }
    }
  }
}
</script>

Documentation on how to activate these features can be found here: https://developers.google.com/gmail/actions/



来源:https://stackoverflow.com/questions/23045754/how-to-add-link-in-subject-of-email-gmail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!