How to send E-mail from a page directly to any email address..??
Please give some ideas or sample code so that I can understand the concept..!
Administrator • Apr 9, 2012
Member • Apr 9, 2012
Which programming language you are using ?TheVSuppose I have a page in which there are lots of fields like name,age,suggestion etc as a textbox. Now I want to sent these field to any email address directly from the click of a button... I tried doing with some library functions but failed to do so. I search google too but didn't got any good example..!
Please give some ideas or sample code so that I can understand the concept..!
import javax.mail.*; import javax.mail.internet.*;We have to define the methods as per our requirement.
Member • Apr 10, 2012
Member • Apr 11, 2012
<html> <body> <form action="form.php" method="post" name="form1" id="form1" onSubmit="return validate(this)"> <table calspan="500" > <tr> <td>Name</td> <td><input type="text" name="name" id="name" /></td> </tr> <input name="hiddenField" type="hidden" id="hiddenField" value="Job Application form from ABC company " /> <tr> <td>E-mail Address</td> <td><input type="text" name="email" id="email" /></td> </tr> </br> <tr> <td>Mobile Number</td> <td><input name="age" type="text" id="age" size="11" maxlength="10" /></td> </tr> </br> <tr> <td>What type of job are you looking for?</td> <td><input name="job" type="radio" id="job" value="programmer" checked="checked" /> Programmer <input type="radio" name="job" id="designer" value="designer" /> Designer <input type="radio" name="job" id="manager" value="manager" /> Manager </td> </tr> <tr> <td>Paste your resume hear (Press ctrt + v hear....)</td> <td> <textarea name="address" id="address" cols="30" rows="3"></textarea> <td> </tr> <tr> <td>Which programming languages do you work with?</td> <td><input name="languages1" type="checkbox" id="languages1" value="php" checked="checked" /> PHP <input type="checkbox" name="languages2" value="html" id="languages1" /> Java <input type="checkbox" name="languages3" value="javascript" id="languages2" /> .NET </td> </tr> <tr> <td>Langueges Known</td> <td> <select name="daysavailable[]" size="4" multiple="multiple" id="daysavailable[]"> <option value="English" selected="selected">English</option> <option value="Hindi">Hindi</option> <option value="Telugu">Telugu</option> <option value="Tamil">Tamil</option> </select> To select multiple Langueges drag over the Langueges, to select altnernate Langueges Ctrl-click on the Languege . </td> </tr> <tr> <td>How do you prefer to be contacted?</td> <td> <select name="contact" id="contact"> <option value="phone">Phone</option> <option value="email">E-mail</option> </select> </td> </tr> </table> </br> <input type="submit" name="button" id="button" value="Send " /> <input type="reset" name="button2" id="button2" value="Reset" /> <br /><br /><br /> [b]Privacy Policy[/b]: the information you provide will not be shared it is only for the use in our selection of potential employees. <br /><br /> </form> </body> </html>The bellow php code sends the data to your mail
<?php // validate each of the variables in the form $name = $_POST['name']; $hiddenField = $_POST['hiddenField']; $email = $_POST['email']; $age = $_POST['age']; $job = $_POST['job']; $address = $_POST['address']; $languages1 = $_POST['languages1']; $languages2 = $_POST['languages2']; $languages3 = $_POST['languages3']; $daysavailable = $_POST['daysavailable']; $contact = $_POST['contact']; // add date the form was submitted $date = gmdate("M d Y"); // Thank the user print "<center><b>Thank you $name we will get back to you shortly</b></center>"; print "<center>$date</center>"; // Send to specificed email address $to ="pradeepchandramaddirala@gmail.com"; $subject = "Job Application form"; $body =" Date: $date \n Name: $name \n HiddenField: $hiddenField \n Email address: $email \n Mobile Number: $age \n Job: $job \n Resume: $address \n Programing Languages: $languages1 $languages2 $languages3 \n Languege Known: $daysavailable[0] $daysavailable[1] $daysavailable[2] $daysavailable[4] \n Contact: $contact \n\n"; mail($to,$subject,$body); ?>
Member • May 13, 2012