Tutorial :Sending a HTML email with a midi file that needs to play automatic on open



Question:

I'm trying to accomplish the following, I'm sending a HTML email using PHP Mailer that reads a html file and embedding a midi file within the HTML file, and it then sends out the email and then the midi file should start playing automatically once the email is opened, is this possible, since it does not seem to work, I'm using Evolution to view the email.

My code looks like this,

HTML FILE "If i open this in my browser it plays but not in email"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">    <head>      <title>Template</title>  </head>  <body>        <h1>Song is playing</h1>      <embed src="http://test.mydomain.co.za/song.mid" autostart="true" loop="true" hidden="true" />  </body>  </html>  

PHP Mailer code

    $email = $_GET['email'];        //Including the PHP mailer class      require_once 'class.phpmailer.php';        $mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch        try {        $mail->AddAddress($email);        $mail->SetFrom('webmaster@mydomain.co.za', 'Webmaster');        $mail->AddReplyTo('webmaster@mydomain.co.za', 'Webmaster');        $mail->Subject = 'PHPMailer Test Subject via mail(), advanced';          $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically          $mail->MsgHTML(file_get_contents('template.html'));        $mail->Send();        echo "Message Sent OK</p>\n";       }catch (phpmailerException $e) {         echo $e->errorMessage(); //Pretty error messages from PHPMailer       } catch (Exception $e) {        echo $e->getMessage(); //Boring error messages from anything else!      }  ?>  

Is this at all possible? And how?


Solution:1

Others are already told you why it's a bad idea, so I am going to skip that.

There is no reliable way to do what you want.

Not even in browsers, and we only have a few popular ones. But when you're dealing with email clients, you have to deal with desktop clients (even the ones that are crossplatfom can behave differently) and web-based clients, together you get a gazillion ways why your idea is impossible.


Solution:2

That would be the most annoying email in the world!

Thankfully, most mail clients do not recognise media tags or embedded flash.


Solution:3

Don't. Seriously. If you want the mail recipient to get the midi, then put a link in the body of the mail. The only thing I can imagine more annoying than a web page that automatically plays music is an email that does.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »