How to send E-mail from a page directly to any email address..??

TheV

TheV

@thev-iGmS6y Oct 26, 2024
Suppose 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..!

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Apr 9, 2012

    How about configuring any existing SMTP server (like Gmail) with your page? That's the easiest and the best way to send email from any page.
  • K!r@nS!ngu

    K!r@nS!ngu

    @kr-at-nsngu-XqzcfU Apr 9, 2012

    TheV
    Suppose 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..!
    Which programming language you are using ?
    Every language will have seperate library functions, in which the SMTP server configuration will be defined.
    Suppose in JAVA The header files are :
    import javax.mail.*;
    import javax.mail.internet.*; 
    We have to define the methods as per our requirement.
  • TheV

    TheV

    @thev-iGmS6y Apr 10, 2012

    I am using j2ee technology. I am working on web Application in which I have a suggestion box from which a user can write anything and just click a button to sent a email to administrator.
    I am using NETBEAN 7.1 IDE so what library should I use and how to configure I don't know anything about it. How do I start ..please give any sample code so I can understand. ..
  • deepu11111111

    deepu11111111

    @deepu11111111-Vg940z Apr 11, 2012

    Nice #-Link-Snipped-#
    You can send the data that entered in the text fields to your mail through Php
    Here is the code
    <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);
    ?>
  • SKsinha

    SKsinha

    @sksinha-kRUoVz May 13, 2012

    Thanks for sharing this PHP script. I had a similar script used on one of my HTML website but the problem there was if I use any google or yahoo mail account then it is not delivered either or delivered with #-Link-Snipped-# not in the name/email id of sender. Changing the email id to one of those configured with site hosting, results were as desired. Now I am using another script but could never solve this problem, don't know where the problem was ? at my server or in the script ?