2010-03-08 111 views
8

我正在从一个电子邮件提交表单的项目。情景是这样的。我们会发送一份表格给客户需要填写表格的电子邮件列表,当他们提交时,表格应该被提交,服务器应该能够检索填写人员提供的值。当我尝试过,它没有考虑提交按钮,因为表单提交并且没有执行任何操作。任何人都可以帮助我解决这个问题。提前致谢。从电子邮件提交表格

+0

你在写什么?你有代码来证明你的问题?没有更多的信息,我们可以做的不多。 – JasCav 2010-03-08 16:19:11

+3

你在这里打败了一场失败的战斗。许多电子邮件客户端将严格限制您可以在HTML电子邮件中包含哪些标记,以避免很多功能无法实现。 GMail,Yahoo! Mail和Hotmail尤其具有挑战性。我建议在Web服务器上托管表单,并通过电子邮件提供链接。你在浪费你的时间试图让表单通过电子邮件工作。 – Asaph 2010-03-08 16:21:34

+0

最令人印象深刻的案例是新的Outlook。完全删除文本输入/文本区和按钮。 – Shikiryu 2010-10-15 14:15:57

回答

7

HTML表单和客户端代码通常受限于大多数电子邮件客户端。这是一个明显的攻击媒介,因此在处理基于HTML的电子邮件时,您的能力有限。

我建议提供一个网页链接。

2

提交通过电子邮件形式是可能的, 我写(使用PHP SwiftMailer)发送电子邮件的代码,

//Create the Transport 
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl") 
    ->setUsername('[email protected]') 
    ->setPassword('*****') 
    ; 
//Create the Mailer using your created Transport 
$mailer = Swift_Mailer::newInstance($transport); 
//Create a message 
$message = Swift_Message::newInstance('Fill the form') 
    ->setFrom(array('[email protected]' => 'Harry')) 
    ->setTo(array('[email protected]','[email protected]')) 
    ->setBody('<html>' . 
      ' <head></head>' . 
      ' <body>'. 
      ' <form action="http://www.our_domail.com/index.php" method="get">'. 
      ' <label>Name: </label><input type="input" id="name" name="name"/><br/>' . 
      ' <label>phone: </label><input type="input" id="phone" name="phone" /><br/>'. 
      ' <label>About you: </label><br/>'. 
      ' <textarea id="about" name="textb"></textarea> <input type="submit" value="submit" />'. 
      ' </form>'. 
      ' </body>' . 
      '</html>', 
      'text/html') 
    ; 
    //Send the message 
    if ($mailer->send($message)) 
    { 
    echo "Sent\n"; 
    } 
    else 
    { 
    echo "Failed\n"; 
    } 

在邮件箱中我得到的形式,这在提交显示像You are submitting information to an external page. Are you sure?一些消息和Although this page is encrypted, the information you have entered is to be sent over an unencrypted connection and could easily be read by a third party. Are you sure you want to continue sending this information? 在点击继续时,它会发送到我的服务器与表单中的数据。我不确定我们可以在表单中使用JavaScript验证或CSS样式表。 备注:This was tested in Gmail server and i don't know about other mail servers.

其实这对我有用,希望它对你也有帮助..

+1

显然不会在Outlook中工作:http://www.campaignmonitor.com/resources/will-it-work/forms/ – 2013-12-05 17:48:28