tags:

views:

46

answers:

2

I was working on a project to submit a form from an email. The scenario is this. We will send a form to list of emails where in the customer has to fill in the form and once they hit submit, the form should be submitted and server should be able to retrieve the values that is provided by the person filling in.When i tried, it was not considering the submit button as form submit and no action is being performed. Can anyone help me to resolve this. Thanks in advance.

+4  A: 

HTML forms and client side code are typically restricted from most email clients. This is an obvious attack vector and as such your abilities are limited when dealing with HTML based email.

I would recommend providing a link to a web page.

Dan
A: 

Submitting a Form through Email is possible, The code i wrote to send Email(using 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";
  }

In the Mail Box i got the form, which on submitting shows some messages like You are submitting information to an external page. Are you sure? and 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? On clicking on Continue, it gets posted to my server with data in the form. i am not sure about that we can use javascript validations or css stylesheets in our forms. Note: This was tested in Gmail server and i don't know about other mail servers..

Actually this worked for me, hope it helped you too..

Harish Kurup