View Full Version : smtp e-mail and php
itila
11-20-2009, 07:43 PM
I'm trying to set up a contact page for my website. The form seems to work and I added the necessary php code to the top of the processing page:
<?php
$to = "crys.bay@forbiddenislandchronicles.com";
$subject = "New author question";
$headers = "From: webmaster@forbiddenislandchronicles.com\n";
$body = "$_POST['question'];
mail($to,$subject,$headers,$body);
?>
However, the server isn't e-mailing the page to me. How can I enable smtp e-mail delivery? What am I doing wrong?
felgall
11-20-2009, 08:01 PM
mail($to,$subject,$body,$headers);
itila
02-24-2010, 03:17 PM
Thanks for the help! So here's a new concern: I'm trying to put multiple variables into the body, but I'm not being allowed to do any kind of formatting. So for example, instead of reading Name: Mr. John Doe, it reads Mr.JohnDoe.
Here's the code:
$body = "Name: " . $_POST['title'] . $_POST['first_name'] . $_POST['last_name'];
What command should I use to seperate the . $_POST[]
felgall
02-24-2010, 06:09 PM
What command should I use to seperate the . $_POST[]
Whatever characters you want between them to get a space use:
$body = "Name: " . $_POST['title'] . ' ' . $_POST['first_name'] . ' ' . $_POST['last_name'];
itila
03-02-2010, 01:15 PM
Thanks for being patient. I think I am nearing the end of my questions. I'm trying to add a line break in the e-mail text. I tried this:
$body = "Name: " . $_POST['title'] . " " . $_POST['first_name'] . " " . $_POST['last_name'] . <br> . $_POST['email'];
but it didn't work. What should I do instead?
felgall
03-02-2010, 01:38 PM
$body = "Name: " . $_POST['title'] . " " . $_POST['first_name'] . " " . $_POST['last_name'] . "\n". $_POST['email'];
itila
03-04-2010, 08:14 AM
I finished all my form coding! Thanks so much for your help!
itila
03-12-2010, 12:40 PM
Hi,
I decided to add one more form to my website so that readers could send recommendations directly to each other. Everything in the code works except:
$to = ". $POST['friend_email']";
Help?
felgall
03-12-2010, 12:58 PM
You have:
$to = ".
which should be
$to = ''.
with spaces added between each character for clarity that's:
$ t o = ' ' .
not
$ t o = " .
itila
03-12-2010, 01:53 PM
I tried the coding you suggested. When I entered data into the live form, I received this error code:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home2/forbidd5/public_html/recommendation_sent.php on line 2
Here's line 2 once again:
$to = ''. $_POST['friend_email']'';
Corey Cole
03-12-2010, 03:18 PM
That code doesn't make any sense. The idea of the dot operator (".") is to connect strings together. It doesn't belong inside a string. Your code should read:
$to = $_POST['friend_email'];
If you were changing your "From" header, you might build that by saying:
$header = "From: " . $my_email_address;
assuming you had your return address in that variable. But you don't want to put quotation marks around the dot or the variable name.
-----------
I tried the coding you suggested. When I entered data into the live form, I received this error code:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home2/forbidd5/public_html/recommendation_sent.php on line 2
Here's line 2 once again:
$to = ''. $_POST['friend_email']'';
felgall
03-12-2010, 03:45 PM
Try
$to = $_POST['friend_email'];
itila
03-12-2010, 06:15 PM
Thank you!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.