Incorporating video in the email message?

Hello guys

i’m trying to incorporate a video from youtube.com inside my email content.

but it doesn’t work.

here is the codes below,


<?php
 
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = false;
$mail->Username = “contact+coder9.com”;
$mail->Password = “mypasswordhere”;
$mail->Host = "localhost"; // SMTP server
$mail->From = "contact@coder9.com";
$mail->AddAddress("iridion_us@yahoo.com");
$mail->Subject = "first mail";


$mail->Body = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Untitled Document</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
</head>
<body>
<table width='600' height='522' border='0' cellspacing='0'>
  <tr>
    <td height='100' bgcolor='#FF0000'><div align='center'><img src='http://coder9.com/odesk/email/images/banner.jpg' alt='' name='bannerholder' width='600' height='100' id='bannerholder' /></div></td>
  </tr>
  <tr>
    <td height='393' bgcolor='#000000'><div align='center'><object width='560' height='340'><param name='movie' value='http://www.youtube-nocookie.com/v/pIv7fdbqZgk&hl=en_US&fs=1&rel=0'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube-nocookie.com/v/pIv7fdbqZgk&hl=en_US&fs=1&rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='560' height='340'></embed></object></div></td>
  </tr>
  <tr>
    <td height='100'><div align='center'><img src='images/flowers.jpg' alt='' name='holderflower' width='116' height='116' id='holderflower' /></div></td>
  </tr>
</table>
</body>
</html>";


$mail->WordWrap = 50;
 
if(!$mail->Send())
{
   echo "Message was not sent";
   echo "Mailer Error: " . $mail->ErrorInfo;
} else {
   echo "Message has been sent";
}
 
?>


i hope someone can help me.

thanks in advance.

I always go to this site for email issues. It’s always very informative:

have look at these as well
http://www.email-marketing-reports.com/iland/2008/09/video-email-update-can-you-embed-them.html

Please see this link http://stylecampaign.com/blog/?p=29

You have to prepare a multipart email on say php
most important part is use of dynsrc and mce_src with cid
and base_64 encoding,

Note : “it may work only on outlook client, and in other browser client
the video file will go as an attachment inline. I am not yet sure, please see”

Please pass base_64 encoded data to $video variable
and html data to $body

And use this function test video mail and check in various client like outlook.

$body=‘<div align=“center” width=“100%” height=“100%” style=“padding-top:40px”>
<img src=“http://www.bitfad.com/download/But.gif” mce_src=“cid:Spark.mpg” dynsrc=“cid:Spark.mpg” width=“384” height=“222”/>
<div>’;

$video=‘AAABsxgA0hMEACCkAAABuAAIAEAAAAEAAAnr2AAAAQFSl+H0pSIuUpSIuUpSIuUpF4ixSZ5Y
i2/nGv2q/2z24DOyXiLyDBcUI+4+r3yc+hEXI/bnwtoAclb/d9EXSkhFJMYRbyaBQspaAnE’;

SendTestMail(‘to@tomail.com’,‘l@frommail.com’,‘from@frommail.com’,‘test subject’,$body,true,$video,$encoding=“utf-8”);

function SendTestMail($emailaddress,$from,$fromaddress,$emailsubject=“”,$body=“”, $html = true,$video=“”,$encoding=“utf-8”)
{
if (strtoupper(substr(PHP_OS,0,3)==‘WIN’)) {
$eol=“”;
} elseif (strtoupper(substr(PHP_OS,0,3)==‘MAC’)) {
$eol=“\r”;
} else {
$eol="
";
}

$msg = “”;

$headers .= “From: “.$from.” <”.$fromaddress.“>”.$eol;

$headers .= “Reply-To: “.$from.” <”.$fromaddress.“>”.$eol;

$headers .= “Return-Path: “.$from.” <”.$fromaddress.“>”.$eol;

$headers .= “Message-ID: <”.time()." TheSystem@“.$_SERVER[‘SERVER_NAME’].”>".$eol;

$headers .= “X-Mailer: PHP v”.phpversion().$eol;

$headers .= ‘MIME-Version: 1.0’.$eol;

if (!empty($video)) {

$mime_boundary=md5(time());

$headers .= “Content-Type: multipart/related; boundary=\”“.$mime_boundary.”\“”.$eol;

$f_contents = $video;

// text OR html part

$msg .= “Content-Type: multipart/alternative”.$eol;
$contentType = “text/plain”;

if ($html) {
$contentType = “text/html”;
}

$msg .= “–”.$mime_boundary.$eol;

$msg .= “Content-Type: “.$contentType.”; charset=\”“.$encoding.”\“”.$eol;

$msg .= “Content-Transfer-Encoding: 8bit”.$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!

$msg .= $body.$eol.$eol;

$msg .= “–”.$mime_boundary.$eol;
$msg .= “Content-Type: application/octet-stream; name=spark.mpg”.$eol;
$msg .= “Content-Transfer-Encoding: base64”.$eol;
$msg .= “Content-Disposition: INLINE”.$eol.$eol;
$msg .= $f_contents.$eol.$eol;

$msg .= “–”.$mime_boundary.“–”.$eol.$eol; // finish with two eol’s
} else {
$headers .= “Content-Type: text/plain; charset=\”“.$encoding.”\“”.$eol;
$headers .= “Content-Transfer-Encoding: 8bit”.$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
$msg .= $body.$eol.$eol;
}

ini_set(sendmail_from, $fromaddress); //needed to hopefully get by spam filters.
$success = mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);
return $success;
}