TheYodaPagoda Posted April 13, 2004 Posted April 13, 2004 Hey everyone, I'm doing some tutorials for Dreamweaver MX...and I keep coming across a parse error when I have PHP send email. Is that not supported on this service? I'm not sure how to enable it, or what to do for that matter. I'd like to have this function work, or at least tell me I'm doing the correct script! Thanks, Yoda Quote
kaseytraeger Posted April 13, 2004 Posted April 13, 2004 Yes, you can send mail using PHP. My web site is hosted with TCH and uses a PHP script to send email. Can you copy your error message and post it here for us to review? Quote
TheYodaPagoda Posted April 13, 2004 Author Posted April 13, 2004 Why certainly! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><?php mail(youremail@******', 'This is the message subject', 'This is the message body.'; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> </body> </html> Perhaps I should read closer...You want the error message? Parse error: parse error in /home/blah/blah/blah/newland/mailtest.php on line 2 Quote
btrfld Posted April 13, 2004 Posted April 13, 2004 Looks like the error is that you left off the closing paren on the mail() function. <?php mail(youremail@******', 'This is the message subject', 'This is the message body.'; ?> Quote
TheYodaPagoda Posted April 13, 2004 Author Posted April 13, 2004 Looks like the error is that you left off the closing paren on the mail() function.<?php mail(youremail@******', 'This is the message subject', 'This is the message body.'; ?> You're absolutely right...it worked! Thanks for telling me what I should have been able to check for myself I'll check my parens from now on! Yoda Quote
stevevan Posted April 13, 2004 Posted April 13, 2004 Don't feel bad! I once spent nearly 2 hours wondering why a program I was writing for a class didn't work. Come to find out I was missing one (1) semi-colon. Doh! Quote
TheYodaPagoda Posted April 14, 2004 Author Posted April 14, 2004 Does anyone have any ideas about how to include a sender in the PHP mail() function? In my example, I created a web form for contacting the website, and it inputs the sender's name, but PHP doesn't have 'sender' built in somehow. The way I have it set up now, just to give the example some functionality, is to send the person an email straight back to them...I figured, that 'emailAddress' variable was being wasted Here is the example site: Newland Tours Contact Page And...here is the example of the code I'm using, variables included: <?php mail($_POST['emailAddress'], $_POST['subject'], $_POST['body']); ?> Any help would be appreciated Yoda Quote
TCH-Bruce Posted April 14, 2004 Posted April 14, 2004 You might want to take a look at the Ultimate Form Mailer script. It was designed to do exactly what you want. Quote
TCH-Don Posted April 14, 2004 Posted April 14, 2004 >mail($myemail, $subject, $message, $from); I think this is the format. Quote
TheYodaPagoda Posted April 14, 2004 Author Posted April 14, 2004 Thanks for all your help guys! I did end up finding a solution, by of course, assigning some variables <?php$from = "$_POST['emailAddress']"; $header = "From: $from/r/n"; mail(youremail@******, $_POST['subject'], $_POST['message'], $header); ?> That code may, or may not be precise, because I'm coding it from memory...but it works! Yoda Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.