Incorporating video in the email message?

Hello guys

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

but it doesn’t work.

here is the codes below,

$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = false;
$mail->Username = “”;
$mail->Password = “mypasswordhere”;
$mail->Host = "localhost"; // SMTP server
$mail->From = "";
$mail->Subject = "first mail";

$mail->Body = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' ''>
<html xmlns=''>
<title>Untitled Document</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
<table width='600' height='522' border='0' cellspacing='0'>
    <td height='100' bgcolor='#FF0000'><div align='center'><img src='' alt='' name='bannerholder' width='600' height='100' id='bannerholder' /></div></td>
    <td height='393' bgcolor='#000000'><div align='center'><object width='560' height='340'><param name='movie' value=''></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='560' height='340'></embed></object></div></td>
    <td height='100'><div align='center'><img src='images/flowers.jpg' alt='' name='holderflower' width='116' height='116' id='holderflower' /></div></td>

$mail->WordWrap = 50;
   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

Please see this link

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=“” mce_src=“cid:Spark.mpg” dynsrc=“cid:Spark.mpg” width=“384” height=“222”/>


SendTestMail(‘’,‘’,‘’,‘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’)) {
} elseif (strtoupper(substr(PHP_OS,0,3)==‘MAC’)) {
} else {

$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)) {


$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);
return $success;