Click here to Skip to main content
15,072,051 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I had created html web form and i want that form to be in my email...i have written some javascipt code but when i click send button automatically MS-Outlook will pop up i don't want its to be pop up and directly i want to send html page to gmail of my account...... can anybody please help me out for this.....
Posted
Updated 29-Apr-20 17:36pm
Comments
Jim Jos 18-May-12 4:13am
   
Coud you put the code in the javascript?

Suppose you have an html or php page something like this:
HTML
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td>Contact Form </td>
</tr>
</table>

<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_contact.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">Subject</td>
<td width="2%">:</td>
<td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
</tr>
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="50"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>


Create a php file named send_contact.php. Following is its code:
HTML
// Contact subject
$subject ="$subject"; 
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail"; 
// From 
$header="from: $name <$mail_from>";

// Enter your email address
$to ='someone@somewhere.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email 
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>


Now your contact page will send data of your html form to the email stored in $to variable in send_contact.php
   
Comments
Member 12258183 6-Nov-17 10:06am
   
The code of "send_contact.php" is not proper. It has many errors. The Correct Code is a follows:

<?php

if( isset($_POST['Submit']) ) {
// Contact subject
$subject =$_POST["subject"];
// Details
$message=$_POST["detail"];

$name=$_POST["name"];
// Mail of sender
$mail_from=$_POST["customer_mail"];
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='advdpjindal@gmail.com';

$send_contact=mail($to,$subject,$message,$header);
}
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

But still the mail is not received at $to (my mail address). This mail is being thrown in xampp/mailoutput at localhost. Please provide solution how to get it on my gmail a/c from the server (from my site)

D P Jindal
dpjindal@gmail.com
// Contact subject
$subject ="$subject";
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='someone@somewhere.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900