Jump to content

Recommended Posts

Posted

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

Posted

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
Posted

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.'; ?>
Posted
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

Posted

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!

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...