发送带有需要在打开时自动播放的 midi 文件的 HTML 电子邮件

发布于 2024-09-10 14:00:26 字数 2022 浏览 6 评论 0原文

我正在尝试完成以下任务,我使用 PHP Mailer 发送 HTML 电子邮件,该邮件程序读取 html 文件并在 HTML 文件中嵌入 midi 文件,然后发送电子邮件,然后 midi 文件应该开始自动播放一旦电子邮件打开,这可能吗,因为它似乎不起作用,我正在使用 Evolution 来查看电子邮件。

我的代码如下所示,

HTML FILE“如果我在浏览器中打开它,它会播放,但不会在电子邮件中播放”

<!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 代码

    $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('[email protected]', 'Webmaster');
      $mail->AddReplyTo('[email protected]', '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!
    }
?>

这可能吗?又如何呢?

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('[email protected]', 'Webmaster');
      $mail->AddReplyTo('[email protected]', '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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ペ泪落弦音 2024-09-17 14:00:27

不。严重地。如果您希望邮件收件人获取 MIDI,请在邮件正文中放置一个链接。我能想象到的唯一比自动播放音乐的网页更烦人的就是自动播放音乐的电子邮件

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.

雨的味道风的声音 2024-09-17 14:00:26

这将是世界上最烦人的电子邮件

值得庆幸的是,大多数邮件客户端无法识别媒体标签或嵌入式闪存。

That would be the most annoying email in the world!

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

金兰素衣 2024-09-17 14:00:26

其他人已经告诉过你为什么这是一个坏主意,所以我将跳过它。

没有可靠的方法来做你想做的事。

即使在浏览器中也没有,而且我们只有几个流行的。但是,当您处理电子邮件客户端时,您必须处理桌面客户端(即使是跨平台的客户端也可能有不同的行为)和基于 Web 的客户端,在一起您就会得到无数种方法来解释为什么您的想法是不可能的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文