我们可以从静态网站(html页面)发送电子邮件吗?

时间:2013-01-23 06:27:49

标签: html

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

4 个答案:

答案 0 :(得分:1)

仅使用javascript和html,就不可能。 Javascript并不打算做这些事情,并且它与它所在的Web浏览器之外的其他任何东西的交互方式都严重瘫痪。您可以使用mailto:link来触发用户注册邮件客户端的打开。

但是,您可以使用弹出窗口更好地处理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,则可以使用{{1}}。大多数主机支持此功能,instructions for using FormMail很简单。

答案 1 :(得分:1)

可以这样做,但你无法保证结果。

以下代码是合法的:

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

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

答案 2 :(得分:0)

除非您不介意与可以为您执行后端处理的第三方服务提供商进行交互,否则您无法发送仅包含HTML的电子邮件(来自前端)。

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

see this

答案 3 :(得分:0)

如果没有服务器端编码,您只有一个选项可以通过HTML发送电子邮件

<a href="mailto:emailaddress">Email</a>
相关问题