School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,369 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,435 people online right now. Registration is fast and FREE... Join Now!




Simple Email Problem

 

Simple Email Problem

S3lkies

30 Jun, 2009 - 06:25 PM
Post #1

D.I.C Head
**

Joined: 9 Jan, 2009
Posts: 168



Thanked: 2 times
My Contributions
CODE
<Form method="post" action="mailto:Test@Test.com">
<li><p>What is your name?<br />
<input type="text" name="Name" size="40" /></p>

<input type="submit" value="Send Form" />
</form>


I have 2 questions - first up sorry its a stupid question ( I should know it ><) but

1. How do I make it when I recieve the email - it changes the subject to a pre set subject eg

SUBJECT:Message from website

2. How do I make it send from off the website ? - When I press the submit button, it loads up an email on the computer itself - I would rather it send straight from the website?

Thanks aLOT in advance anime1.gif.

User is offlineProfile CardPM
+Quote Post


JayFCox

RE: Simple Email Problem

30 Jun, 2009 - 06:36 PM
Post #2

New D.I.C Head
*

Joined: 31 May, 2009
Posts: 41



Thanked: 5 times
My Contributions
QUOTE(S3lkies @ 30 Jun, 2009 - 06:25 PM) *

CODE
<Form method="post" action="mailto:Test@Test.com">
<li><p>What is your name?<br />
<input type="text" name="Name" size="40" /></p>

<input type="submit" value="Send Form" />
</form>


I have 2 questions - first up sorry its a stupid question ( I should know it ><) but

1. How do I make it when I recieve the email - it changes the subject to a pre set subject eg

SUBJECT:Message from website

2. How do I make it send from off the website ? - When I press the submit button, it loads up an email on the computer itself - I would rather it send straight from the website?

Thanks aLOT in advance anime1.gif.


If you accomplish 2, you can accomplish 1 trivially. But 2 isn't entirely trivial (but fairly simple). If you want to send it from the website, you need to have some code running on the website to send it. To send, your html form would have to post to some page on the website that would process the request to email.

User is offlineProfile CardPM
+Quote Post

no2pencil

RE: Simple Email Problem

30 Jun, 2009 - 06:40 PM
Post #3

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,218



Thanked: 289 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
The important thing to remember about HTML is that it is executed by the viewers browser. Since you want the mail to send from the server, you are going to need to have server side executed code do this. PHP, ASP, cgi/bin, & so on.

PHP mail function
PHP SMTP (direct)
User is online!Profile CardPM
+Quote Post

S3lkies

RE: Simple Email Problem

30 Jun, 2009 - 06:53 PM
Post #4

D.I.C Head
**

Joined: 9 Jan, 2009
Posts: 168



Thanked: 2 times
My Contributions
Thank you both of you - no2pencil, do you mean like

CODE
<title>Contact Us</title>
</head>
<body>
<Title>Contact us</Title>

<a href="Main Page.html">Main Page<a>&nbsp;|&nbsp;<a href="What we do.html">What we do<a>&nbsp;|&nbsp;<a href="About Us.html">About Us<a>

<?php

$myemail = 'Test@test.com';
$subject = 'Contact form from website';

$op = $_POST[op];

if($op == 'contact')
{
    $name = stripslashes($_POST[name]);
    $email = stripslashes($_POST[email]);
    $text = stripslashes($_POST[text]);
    $referer = $_POST[referer];
    $remote_host = $_SERVER[REMOTE_ADDR];
    $server = $_SERVER[SERVER_NAME];
    $browser = $_SERVER[HTTP_USER_AGENT];

    if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",$email))
    {
        $status = "We're sorry, but you've entered an incorrect email address.<br><br><br>

<form method="post" action="<?php print $_SELF; ?>">
<input type="hidden" name="op" value="contact">
<input type="hidden" name="referer" value="<?php print $referer; ?>">
Name*<br><input name="name" size="35" value=""><br>
E-mail address*<br><input name="email" size="35" value=""><br>
<br>Number (for us to get hold of you on (optional))<br><input name="Number"size="35" value=""><br>
<br>Message*<br><textarea name="text" cols="50" rows="10"></textarea><br><br>
<input type="submit" value="Send message!">
</form>

<h5>* is manditory feilds</h5>



</body>
</html>


This post has been edited by S3lkies: 30 Jun, 2009 - 06:55 PM
User is offlineProfile CardPM
+Quote Post

neit

RE: Simple Email Problem

1 Jul, 2009 - 02:33 AM
Post #5

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 137



Thanked: 12 times
My Contributions
thats alot of forum checking which is required
But you will then need the php mail function to send the email to you.

Below is a sample (you will need to change the variables etc.. and integrate it your form)

CODE
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>



User is offlineProfile CardPM
+Quote Post

S3lkies

RE: Simple Email Problem

1 Jul, 2009 - 05:07 PM
Post #6

D.I.C Head
**

Joined: 9 Jan, 2009
Posts: 168



Thanked: 2 times
My Contributions
with the message - I want them to put in what they want - how would I get around doing it? like asking them to put in there email address, message etc.?
User is offlineProfile CardPM
+Quote Post

neit

RE: Simple Email Problem

2 Jul, 2009 - 04:44 AM
Post #7

D.I.C Head
**

Joined: 13 Feb, 2009
Posts: 137



Thanked: 12 times
My Contributions
The messages etc input through the form in your previous script.
Thats all fine you just need to swap the text in the script that showed
you with the varibles you pass through from your form after checking the input then pass these to the mail function
User is offlineProfile CardPM
+Quote Post

S3lkies

RE: Simple Email Problem

5 Jul, 2009 - 05:00 PM
Post #8

D.I.C Head
**

Joined: 9 Jan, 2009
Posts: 168



Thanked: 2 times
My Contributions
Thanks alot =D!.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 09:03PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month