2010-03-08 110 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