I've been working on a email script all day now with no such luck. I thought this would be very easy, but I guess not. None of the email scripts I found seem to work the way I want. I have the form page up fine. It's the action that I'm having trouble with. I don't want the action to be simply mailto:blah@blah.com. Does anyone have a good php script I could use?
Thanks.
vinyl-junkie 09-02-2006, 09:48 PM Have you tried PHPMailer (http://phpmailer.sourceforge.net/)?
mark87 09-02-2006, 09:50 PM I just do something very simple like this...
<?php
$to = "email@email.com";
$subject = "Message from Contact Form";
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$web = $_POST['web'];
$msg = $_POST['msg'];
$body = "Sender: " . $fname . " " . $lname . "\n\nEmail: " . $email . "\n\nWebsite: " . $web . "\n\nMessage:\n\n" . $msg;
if (mail($to, $subject, $body)) { header("Location: sent.html"); }
else { header("Location: error.html"); }
?>
rafiki 09-03-2006, 01:18 PM I've been working on a email script all day now with no such luck. I thought this would be very easy, but I guess not. None of the email scripts I found seem to work the way I want. I have the form page up fine. It's the action that I'm having trouble with. I don't want the action to be simply mailto:blah@blah.com. Does anyone have a good php script I could use?
Thanks.
abel this 1 will work, change the fields to get the message accordingly
<?php
$to = "youremail@yourdomain.com";
$Subject = "yourubjectl";
$message = "NAME: {$_POST['fieldname']} {$_POST['surname']}, DOB:{$_POST['DOB']}, Year in school:
{$_POST['school_year']}, siblings: {$_POST['siblings']}, bedtime: {$_POST['bedtime']},
homework time: {$_POST['homework']}, tv time: {$_POST['tv']}, computer time: {$_POST['computer']},
family time: {$_POST['family']}, time with friends: {$_POST['friends']}";
mail($to,$Subject,$message);
if(mail){
echo "<BR />Thanks, message sent";
}
else{
echo "<BR /> An Error occured";
}
?>
rafiki 09-03-2006, 01:21 PM and this on the page with your form on
<form action="pagewithemailscript.php" method="post">
pkarovsky 09-26-2006, 05:44 PM This is a response to the post from Abel and reply by Rafiki
I used your script pretty much as is except I changed the variable names to match my HTML form and it seemed to work fine except that I didn't receive any email. Any suggestions?
mark87 09-26-2006, 10:42 PM Did you place your email in the variable too?
Is a spam filter blocking the email?
Have you tried specifying a different email to see that works?
Does the page navigate to sent.html (no error occured)?
pkarovsky 09-27-2006, 03:10 AM Mark -- I sent you a private email by mistake, sorry. I'm using the php coding in your posting #3
I get the following error message
Warning: Cannot modify header information - headers already sent by (output started at /home/interven/public_html/mailform.php:9) in /home/interven/public_html/mailform.php on line 21
No, I did not get to "sent.html"
pkarovsky 09-27-2006, 03:25 AM I tried your php code Rafiki and it worked without any errors but I didn't get any email?? I got the "message sent" page.
Once again I used "myusername@yahoo.com" rather than at my domainname.com. Does this matter?
vinyl-junkie 09-27-2006, 03:41 AM Try it from another domain, such as a gmail account. If gmail thinks it's spam, at least it won't get thrown away before you ever see it.
rafiki 09-27-2006, 12:44 PM when i use my mail script i sent it to my gmail inbox and it was actually in my email inbox, not spam, didnt ever try hotmail or yahoo.. also try giving it a subject that doesnt look like a spam mail!
pkarovsky 09-27-2006, 04:17 PM You were right. Yahoo was deleting the message as spam. I changed the subject and then it worked.
I need to send the person to a page rather than just getting the "your message has been sent" however. Can you help with this.
THANKS!
mark87 09-27-2006, 07:02 PM If you're using Rafiki's code, use the if statement from mine instead...
if (mail($to, $subject, $body)) { header("Location: sent.html"); }
else { header("Location: error.html"); }
pkarovsky 09-27-2006, 08:56 PM Thanks to all of you for your help. Much appreciated
pkarovsky 09-28-2006, 04:43 AM Mark -- in response to your post
If you're using Rafiki's code, use the if statement from mine instead...
if (mail($to, $subject, $body)) { header("Location: sent.html"); }
else { header("Location: error.html"); }
I get the following error message:
Warning: Cannot modify header information - headers already sent by (output started at /home/interven/public_html/jsmail.php:9) in /home/interven/public_html/jsmail.php on line 14
pkarovsky 09-28-2006, 04:55 AM Mark87 -- Turns out the emails came even though I got the error message I just sent you. In fact I got 2 emails; one with a subject line and one without.
mark87 09-28-2006, 05:57 PM Sorry I forgot to change the field names... added into rafiki's...
<?php
$to = "youremail@yourdomain.com";
$Subject = "yourubjectl";
$message = "NAME: {$_POST['fieldname']} {$_POST['surname']}, DOB:{$_POST['DOB']}, Year in school:
{$_POST['school_year']}, siblings: {$_POST['siblings']}, bedtime: {$_POST['bedtime']},
homework time: {$_POST['homework']}, tv time: {$_POST['tv']}, computer time: {$_POST['computer']},
family time: {$_POST['family']}, time with friends: {$_POST['friends']}";
mail($to,$Subject,$message);
if(mail){
header("Location: sent.html");
}
else{
header("Location: error.html");
}
?>
I remember seeing a thread with a similar topic and some people posted links to some resources explaining exploits of the mail() function in PHP, at the bottom of the page it gives some tips on preventing it, such as filtering and urldecode() and other things as well.
take a look at this link:
http://www.securephpwiki.com/index.php/Email_Injection
|
|