Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add embed video inside E-mail?

Tags:

php

email

video

Is it possible to add video inside E-Mail Content??

This is my mail Code

$to = '[email protected]';
$sub = 'my Subject';

$msg = '<html><body>';
$msg .= '<table rules="all" style="border: 1px solid #000000" cellpadding="10">';
$msg .= '<caption style="font-size: 18pt"><strong>Feedback from Customers</strong></caption>';
$msg .= "<tr><td width='25'><strong>Name</strong> </td><td width='60'>".strip_tags($_POST['name'])."</td></tr>";
$msg .= "<tr><td><strong>Email</strong> </td><td>" .strip_tags($_POST['mail']) . "</td></tr>";
$msg .= "<tr><td><strong>Country</strong> </td><td>" .strip_tags($_POST['country']) . "</td></tr>";
$msg .= "<tr><td><strong>Message</strong> </td><td>" . strip_tags($_POST['message']). "</td></tr>";
$msg .= "</table>";

//in here i want add viedo

$msg .= "</body></html>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

mail($to, $sub, $msg, $headers);

i want add <iframe width="100%" height="500" src="https://www.youtube.com/embed/zsqtjnHQWQ8" frameborder="0" allowfullscreen=""></iframe> inside email which send to customer.

How i can implement that??

like image 714
Abdulla Nilam Avatar asked Jan 09 '23 05:01

Abdulla Nilam


2 Answers

The use of an iframe in an email message is not well supported. For more information see the Link. Also it is not the correct way to embed a youtube video in email. If you go to YouTube and share a video via email with yourself you can inspect the html content of that email to discover how you should embed the video properly.

A static-clickable image that will redirect the user back to YouTube.

<a href="http://www.youtube.com/watch?v=Bk_6r-b3kqU&feature=em-share_video_user">
 style="text-decoration:none;display:block" 
 class="nonplayable" 
 target="_blank">
  <img src="http://i3.ytimg.com/vi/Bk_6r-b3kqU/mqdefault.jpg" height="274" width="498">
 < /img></a>

A playable video(requires flash player)

<embed width="640" height="385" base="https://www.youtube.com/v/" wmode="opaque" id="swfContainer0" type="application/x-shockwave-flash" src="https://www.youtube.com/v/Bk_6r-b3kqU?border=0&autoplay=1&client=ytapi-google-gmail&version=3&start=0">

It's because of security, it's the same reason you can't put JavaScript or anything external other than images in an email either - it can give the email too much 'power'. (You can put stuff there, it wont be displayed). Sadly this means no reliable flash support either.

Gmail will parse the YouTube links and actually embed them for people who have it enabled.

like image 70
Deep Kakkar Avatar answered Jan 10 '23 18:01

Deep Kakkar


From a User Experience perspective, there are a variety of reasons why embedding video on an Email is not a good idea. Consider the following:

  1. You have no control over what kind of email client your recipients will use. Some people use clients that support only Plaintext. Other clients disable HTML by default.
  2. Anti-spam systems will likely see this kind of content as a threat and block it.
  3. It is not a good practice to make your user allocate inbox space to a video they may or may not want to see. Whenever possible, give your users the choice to consume or not your content.
like image 36
epereira Avatar answered Jan 10 '23 18:01

epereira