从电子邮件提交表单

时间:2010-03-08 16:18:04

标签: html email

我正在开展一个项目,通过电子邮件提交表单。情景是这样的。我们会将一个表单发送到客户必须填写表单的电子邮件列表中,一旦他们点击提交,表单应该提交,服务器应该能够检索填写的人提供的值。当我尝试过,它没有将提交按钮视为表单提交,也没有执行任何操作。任何人都可以帮我解决这个问题。提前谢谢。

2 个答案:

答案 0 :(得分:7)

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

我建议您提供指向网页的链接。

答案 1 :(得分:2)

可以通过电子邮件提交表格, 我编写的代码用于发送电子邮件(使用PHP SwiftMailer),

//Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl") 
  ->setUsername('my_id@gmail.com')
  ->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('me@gmail.com' => 'Harry'))
  ->setTo(array('some_mail1@gmail.com','some_mail2@gmail.com'))
  ->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.

实际上这对我有用,希望它对你有帮助..

相关问题