4

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??

1
  • Can't you use an iframe to accomplish what you wan Commented Jun 8, 2015 at 11:42

2 Answers 2

6

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.

3

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.
1
  • 1) There is a practice called Graceful Degradation.. support what can be supported, provide fallback for features that aren't. For example, many HTML emails come with a link that says "Click here to view in browser", which would be useful in this case.. 2) List of emails that support iframes: campaignmonitor.com/blog/post/3219/do-iframes-work-in-email 3) embedding a video does not mean that the actual video is sent to the inbox. Commented Jun 8, 2015 at 11:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.