Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add link in subject of email (gmail)

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

enter image description here

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 = "[email protected]";
    $to = "[email protected]";
    $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);
}
like image 884
Parag Tyagi Avatar asked Apr 13 '14 17:04

Parag Tyagi


People also ask

Can you hyperlink an email with subject?

To create a link to send email, use <a> tag, with href attribute. The mail to link is added inside the <a> tag. To add a subject, you need to add ? and then include the subject. All this comes inside the <a> tag.

How do I hyperlink a link in an email?

Select the text or picture that you want to display as a hyperlink. Press Ctrl+K. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.


1 Answers

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/

like image 79
Michael Butler Avatar answered Oct 14 '22 06:10

Michael Butler