【问题标题】:Can we send email from static website( html page)?我们可以从静态网站(html页面)发送电子邮件吗?
【发布时间】:2013-01-23 06:27:48
【问题描述】:

我们可以从静态网站(html页面)发送电子邮件吗?不使用 asp.net 或其他(我的意思是没有服务器端技术)。

【问题讨论】:

标签: html


【解决方案1】:

仅使用 javascript 和 html,这是不可能的。 Javascript 不打算做这些事情,并且在与它所在的网络浏览器以外的任何东西交互方面严重受损。您可以使用 mailto: 链接来触发打开用户注册的邮件客户端。

但是,您可以做一个弹出窗口来更好地处理mailto:,例如this 解决方案

var addresses = "";//between the speech mark goes the receptient. Seperate addresses with a ;
var body = ""//write the message text between the speech marks or put a variable in the place of the speech marks
var subject = ""//between the speech marks goes the subject of the message
var href = "mailto:" + addresses + "?"
         + "subject=" + subject + "&"
         + "body=" + body;
var wndMail;
wndMail = window.open(href, "_blank", "scrollbars=yes,resizable=yes,width=10,height=10");
if(wndMail)
{
    wndMail.close();
}

编辑:也许您不能使用服务器端,但如果您的主机提供formmail.cgi,您可以使用它。大多数主机都支持这一点,instructions for using FormMail 很简单。

【讨论】:

    【解决方案2】:

    除非您不介意与可以为您执行后端流程的第三方服务提供商进行交互,否则您不能仅使用 HTML(从前端)发送电子邮件。

    否则,您需要使用后端,最常见和最简单的方法是使用 PHP。

    see this

    【讨论】:

      【解决方案3】:

      没有服务器端编码,您只有一个选择通过 HTML 发送电子邮件,那就是

      <a href="mailto:emailaddress">Email</a>
      

      【讨论】:

      • 如果您对使用第三方代码感兴趣,www.mycontactform.com 是一个不错的去处。它允许您为用户创建电子邮件表单并发送电子邮件。您可以复制他们的 HTML 代码并将其粘贴到您的静态网站。
      【解决方案4】:

      可以这样做,但你不能保证结果。

      以下代码是合法的:

      <form method="post" action="mailto:my_adress@my_website.com" enctype="text/plain">
        <!-- some inputs here, with a submit of course -->
      </form>
      

      但在此之前,请阅读 this。它会告诉你使用它的危险。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-05-31
        • 1970-01-01
        • 1970-01-01
        • 2015-12-22
        • 1970-01-01
        • 2011-12-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多