【问题标题】:How to display the date and time when the html page is sent as an E-Mailhtml页面作为电子邮件发送时如何显示日期和时间
【发布时间】:2020-08-06 17:47:25
【问题描述】:

我已配置发送邮件并能够将所有邮件发送给任意数量的用户。 现在我们运行了一个 cronjob,它每周日凌晨 2:00 启动服务器。此 cronjob 将调用我的脚本以重新启动。我创建了一个 html 页面,它动态选择时间和日期,并将其作为 html 格式的电子邮件发送。但是在邮件中没有显示日期和日期。

任何想法如何让它工作???

**My Code**

To: user1@gmail.com
Subject: Application Server Status on host
Content-Type: text/html; charset="us-ascii"

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Gerrit Server Status</title>
</head>
<body>
    <p>
        <marquee behavior="scroll" bgcolor="yellow" loop="-1" width="30%">
            <i>
               <font color="blue">
                 Application Server status :
                 <strong>
                  <span id="time"></span>
                 </strong>
               </font>
            </i>
         </marquee>
         <br>
         <font color="blue">
         Application Server was restarted and the services are up and running.
    </p>
<script>
    var today = new Date;
    document.getElementById('time').innerHTML= today.toDateString();
</script>
</body>
</html>

我收到的电子邮件有以下数据:

Application Server status : 
Application Server was restarted and the services are up and running.

在实际的 HTML 页面上,它按预期显示日期和时间。

关于为什么在电子邮件中没有显示日期和时间的任何线索???

谢谢你, 阿尼什

【问题讨论】:

    标签: html email dom html-email


    【解决方案1】:

    一般来说电子邮件客户端不会运行 javascript。你在后台用什么? php?如果 php 试试这个:

    <span id="time"><?php echo today.toDateString(); ?> </span>
    

    【讨论】:

    • 没有后端,平面一个简单的html代码。它是一个 cronjob,它触发脚本以重新启动服务并发布脚本成功或失败,它只是使用 sendmail 发送邮件,其内容为 html 格式
    猜你喜欢
    • 1970-01-01
    • 2015-08-28
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    相关资源
    最近更新 更多