Skip to content Skip to sidebar Skip to footer

Submitting A Form From Email

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 h

Solution 1:

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.

Solution 2:

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('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 messageif ($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..

Post a Comment for "Submitting A Form From Email"