【问题标题】:Submitting a form from Email从电子邮件提交表单
【发布时间】:2010-10-15 22:11:07
【问题描述】:

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

【问题讨论】:

  • 你在写什么?你有代码来证明你的问题吗?如果没有更多信息,我们无能为力。
  • 你正在打一场失败的战斗。许多电子邮件客户端会严格限制您可以在 HTML 电子邮件中包含的标记,以至于无法实现许多功能。 GMail,雅虎! Mail 和 Hotmail 尤其具有挑战性。我建议将表单托管在 Web 服务器上并证明电子邮件中的链接。您正在浪费时间尝试通过电子邮件获取表单。
  • 最令人印象深刻的案例是新的 Outlook。完全删除文本输入/文本区域和按钮。

标签: html email


【解决方案1】:

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

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

【讨论】:

    【解决方案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..

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 2011-10-12
    • 2013-09-16
    • 1970-01-01
    • 2013-05-04
    • 2015-03-28
    • 2016-01-26
    相关资源
    最近更新 更多