View Full Version : send email via html
davelf
09-09-2009, 08:36 AM
i'm making a contact form here,
Question:
How to get message from client / user and send it to my email address.
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=2856&stc=1&d=1252485255
When user click send button the user email address and message will be send to my acount.
Thx for all of your help...
prasanthmj
09-09-2009, 11:30 AM
You need to have a server side script (written in PHP for example).
The following tutorials might help:
How to make a web form (http://www.javascript-coder.com/html-form/how-to-make-a-form.phtml)
Email Form 'HowTo's (http://www.html-form-guide.com/email-form/)
You can use a 'ready-made' form mail script (http://www.html-form-guide.com/form-mail/form-mail-script.html) as well.
davelf
09-09-2009, 01:44 PM
thx for reply. That really help..
But is there another suggestion?
What i really need is just the code that get the value from the textfield and textarea and send it directly to my email account.
forum_amnesiac
09-09-2009, 02:39 PM
You definitely need to use a server side script like PHP.
These scripts can be very simple, I've posted examples of this in this forum before.
Here is a simple PHP script to create an email from data collected in a form:
<?php
//variables
//form contents
$txtMessage=$_POST['message'];
$txtMail=$_POST['email'];
$txtMessage = str_replace(array("\n","\r"),'',$txtMessage);
$txtEmail = str_replace(array("\n","\r"),'',$txtMail);
$Myemail="your email address here";
$message ="Message :\t$txtMessage\n
\n"
$subject = "Message from - ".$txtEmail;
$mailheaders = "From: $txtEmail <> \n";
$mailheaders .= "Reply-To: $txtEmail\n\n";
//send mail
mail($Myemail, $subject, $message , $mailheaders);
?>
The variables 'email' and 'message' are the names of input fields in your form.
Save the above PHP to a php file, eg process.php, and in your <form> tag you add, method="POST" action="process.php".
This is a simple example of creating an email, you can add more fields from the input form quite easily.
davelf
09-10-2009, 01:03 AM
hi, forum_amnesiac thx a lot for your help. I'll this at my contact form.
One last question:
is that possible to use javascript to make my contact form worked?
because i don't have any experience in PHP. So if there's javascript code to solve this problem, share with me please...
but one's again thx for forum_amnesiac and prasanthmj:)
X96 Web Design
09-10-2009, 03:12 AM
Nope - JavScript won't work, it's Client-Side, you need Server-Side.
Most modern hosting providers support PHP, if they don't, then you should really consider switching to a better host....
Cheers,
X96
davelf
09-10-2009, 03:27 AM
oow, ok thx. Just want extra information.:)
thetestingsite
09-10-2009, 03:33 AM
There are also things called "Remotely Hosted Scripts" which is just what you were looking for in your original post and only require a little bit of code that you have to place in your HTML page. Do a Google search for "Remote Hosted Contact Form".
Hope this helps.
davelf
09-10-2009, 08:36 AM
thx for all the reply, i've change my mind and follow all of your suggestion, i will use the php script to handle this contact form.:)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.