-
August 29th, 2016, 09:22 AM
#1
Sort of new to PHP, email question
Hello,
I'm trying out this code to see if a message I wrote goes to a specific email address. Below my code only has the Name, Your Email, and Your Message fields. When I click on Send email after being finished writing something in the Your Message field, it doesn't work. What should I do to fix this? Thanks for taking the time to read.
Code:
<!DOCTYPE html>
02
<html>
03
<head>
04
<title>Website Name</title>
05
</head>
06
<body>
07
08
</body>
09
</html>
10
11
<?php
12
$action=$_REQUEST['action'];
13
if ($action=="") /* display the contact form */
14
{
15
?>
16
<form action="" method="POST" enctype="multipart/form-data">
17
<input type="hidden" name="action" value="submit">
18
Your name:<br>
19
<input name="name" type="text" value="" size="30"/><br>
20
Your email:<br>
21
<input name="email" type="text" value="" size="30"/><br>
22
Your message:<br>
23
<textarea name="message" rows="7" cols="30"></textarea><br>
24
<input type="submit" value="Send email"/>
25
</form>
26
<?php
27
}
28
else /* send the submitted data */
29
{
30
$name=$_REQUEST['name'];
31
$email=$_REQUEST['email'];
32
$message=$_REQUEST['message'];
33
if (($name=="")||($email=="")||($message==""))
34
{
35
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
36
}
37
else{
38
$from="From: $name<$email>\r\nReturn-path: $email";
39
$subject="Message sent using your contact form";
40
mail("youremail@yoursite.com", $subject, $message, $from);
41
echo "Email sent!";
42
}
43
}
44
?>
-
September 4th, 2016, 03:11 PM
#2
Re: Sort of new to PHP, email question
First off, are you receiving any PHP errors?
Second, is this code run on a hosted site or your own local web server? If it's on a host, have you confirmed that PHP's mail sending is configured?
Third, "youremail@yoursite.com" is not a valid e-mail address. Did you just add that to the code example for us to see?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 6th, 2016, 02:45 AM
#3
Re: Sort of new to PHP, email question
Originally Posted by PeejAvery
First off, are you receiving any PHP errors?
Second, is this code run on a hosted site or your own local web server? If it's on a host, have you confirmed that PHP's mail sending is configured?
Third, "youremail@yoursite.com" is not a valid e-mail address. Did you just add that to the code example for us to see?
- No, there is no specific error. everything just went to standout
- Local web server
- yes, set it as an example.
-
September 13th, 2016, 09:18 PM
#4
Re: Sort of new to PHP, email question
Are you sure you have configured your local web server to point to a correct SMTP server?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|