• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Easy PHP Email Script Question

I need to make a sender and a subject show up when the email is sent. Where would I put  it?


<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$childsname = $_POST['childsname'];
$childsage = $_POST['childsage'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$dayphone = $_POST['dayphone'];
$evephone = $_POST['evephone'];
$class1 = $_POST['class1'];
$class2 = $_POST['class2'];


if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}

if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back Button To Make Changes</h2>\n";
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = "$todayis [EST] \n
Attention: $attn \n
From: $visitor ($visitormail)\n
Childs Name: $childsname \n
Childs Age: $childsage \n
Address: $address \n
Address2: $address2 \n
City: $city \n
State: $state \n
Zip: $zip \n
Class1: $class1 \n
Class2: $class2 \n
Daytime Phone: $dayphone \n
Evening Phone: $evephone \n
Message: $notes \n
";

$from = "From: $visitormail\r\n";


mail("info@shelburneartcenter.org", $subject, $message, $from);

?>

Thanks
Ryan
0
catonthecouchproductions
Asked:
catonthecouchproductions
2 Solutions
 
nizsmoDeveloperCommented:
A simple example which shows where to put subject and sender email address:

<?
$email = $_GET['email'] ;
$message = $_GET['message'] ;

// This is the important line below
mail( "yourname@example.com", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>


For a simple tutorial and more examples and explanation, go here:
http://www.daniweb.com/forums/post188143.html

Let me know how you get on.
0
 
DeeEmmCommented:
You can check if the mail has been sent correctly and then show the info you require by replacing the line

mail("info@shelburneartcenter.org", $subject, $message, $from);

with

if (@mail("info@shelburneartcenter.org", $subject, $message, $from);) {
       echo "<h2>Your message has been sent</h2><br>\n";
       echo "<h2>Message sent by - " . $from . "</h2><br>\n";
       echo "<h2>Message subject - " . $subject . "</h2><br>\n";
} else {
       echo "<h2>Sorry, there has been a problem, your message has not been sent</h2><br>\n";
}      
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now