Hello friends-- I'm very new to PHP and was provided this script by a friend who showed me it working about 7 months ago. I am now trying to use it on another site, basically this will e-mail a bunch of info from a form and send an e-mail out. However, I am getting a parse error:
[INDENT]
Parse error: syntax error, unexpected '<' in /home/mshconst/public_html/scripts/php-contact-info.php on line 10[/INDENT]

Please help, here is my code:

<?php

$message = "";

// User Defined

$subject = "MSH WEBSITE INFO REQUEST";

$to = "who its to";
$to_email =  <mailto:email@hotmail.com> "email@hotmail.com";

$from = "MSH Construction Online";
$from_email =  <mailto:email@yahoo.com>
"PMT Info";

$message .= "Name:" + $_POST["Name"] + "\n"
$message .= "Company:" + $_POST["Company_Name"] + "\n"
$message .= "Address1:" + $_POST["Address1"] + "\n"
$message .= "Address2:" + $_POST["Address2"] + "\n"
$message .= "City:" + $_POST["City"] + "\n"
$message .= "State:" + $_POST["State"] + "\n"
$message .= "Zip Code:" + $_POST["Zip"] + "\n"
$message .= "Country:" + $_POST["country"] + "\n"
$message .= "Phone:" + $_POST["phone"] + "\n"
$message .= "Fax:" + $_POST["fax"] + "\n"
$message .= "E-mail:" + $_POST["email"] + "\n"
$message .= "Industry Type" + $_POST["IndustryType"] + "\n"
$message .= "Other Questions or Comments:" + $_POST["Questions_Comments"] + "\n"

// where form_variable_names are the variables the form elements are named

// Auto Built

$target = '"' . $to . '" <' . $to_email . '>';
$additional_headers = ""
. 'Return-Path: "' . $from . '" <' . $from_email . ">\n" 
. 'From: "' . $from . '" <' . $from_email . ">\n"
. 'Reply-To: "' . $from . '" <' . $from_email . ">\n"
. 'X-Mailer: PHP"' . phpversion() . '"' . "\n"
. 'X-From-IP: "' . $user_ip . '"' . "\n"; 

mail( $target, $subject, $message, $additional_headers );

?>

[ Mod Edit - bpat1434 ] Added php tags, removed full email addresses.

    The issue is that you introduce a string without encapsulating it. Based upon the rest of your script, it seems that you want to delete / remove everything between the equals sign and the first '"' character. So it should look like:

    $to_email = "email@email.com";

      Basically, you want to store the string <mailto:example@hotmail.com> "example@hotmail.com" into the $to_email variable (you're having a similar problem with the $from_email variable).

      In order to do this, you need to surround the string in quotes. Since you use double quotes inside the string, I would suggest you simply use single quotes, like so:

      $to_email = '<mailto:example@hotmail.com> "example@hotmail.com"';

      For more information, read in the manual about what a [man]string[/man] is.

      Also, I've removed the actual e-mail addresses from your post - don't want to collect spam, do you? 😉

      EDIT: OI! Bpat! Lay off, I was here first! :p

      EDIT2: Also, unless you have had problems doing this in the past (meaning you have a poor-quality MTA installed on your server), the line endings after all of the headers in the mail() command should be CRLF's, or "\r\n", as described on the manual page for the mail() function: [man]function.mail[/man].

        Hey guys-

        So your suggestion worked, but now I get a new error:

        Parse error: syntax error, unexpected T_VARIABLE in /home/mshconst/public_html/scripts/php-contact-info.php on line 16

        Any thoughts??

        Pete

          On all those $message .= . . . lines, you do not have terminating semi-colons. Also, you want to replace the "+" characters with "." characters, as "." is the concatenation operator in PHP.

            It doesn't look like my e-mail was sent-- I have filled out my form and clicked "submit" now the user is taken to my PHP code and it appears no e-mail information has been sent....any thoughts?

              1. Echo out the different variables used in the mail() call. Visually inspect them - do they look right?

              2. Check if mail() returned false.

              3. Change the line endings to \r\n as I described above.

              4. Check your spam folder.

                1. Echo out the different variables used in the mail() call. Visually inspect them - do they look right?

                1. Check if mail() returned false.

                2. Change the line endings to \r\n as I described above.

                3. Check your spam folder.

                1)-- As you know, I am very, very new to PHP, so please bare this in mind when helping me out-- this is very much appreciated.-- How do you "Echo Out" the different variables?

                2) How do I check if a line of code returns true or false?

                3) Do I change all line endings? and what does \r\n actually do?

                4) Nothing came into my spam folder either!

                Pete

                  The line-ending shouldn't matter in the message body, but they definitely can matter in the headers:

                  $additional_headers = ""
                  . 'Return-Path: "' . $from . '" <' . $from_email . ">\r\n"
                  . 'From: "' . $from . '" <' . $from_email . ">\r\n"
                  . 'Reply-To: "' . $from . '" <' . $from_email . ">\r\n"
                  . 'X-Mailer: PHP"' . phpversion() . '"' . "\r\n"
                  . 'X-From-IP: "' . $user_ip . '"' . "\r\n";
                  
                    5 days later

                    Here it is, works great!

                    <?php
                    
                    $message = "";
                    
                    // User Defined
                    
                    $subject = "INFO REQUEST";
                    
                    $to = "My Sender Name";
                    $to_email = "email@hotmail.com";
                    
                    $from = "PMT Info";
                    $from_email = "email@yahoo.com";
                    
                    $message .= "Name:" . $_POST["Name"] . "\n";
                    $message .= "Company:" . $_POST["Company_Name"] . "\n";
                    $message .= "Address1:" . $_POST["Address1"] . "\n";
                    $message .= "Address2:" . $_POST["Address2"] . "\n";
                    $message .= "City:" . $_POST["City"] . "\n";
                    $message .= "State:" . $_POST["State"] . "\n";
                    $message .= "Zip Code:" . $_POST["Zip"] . "\n";
                    $message .= "Country:" . $_POST["country"] . "\n";
                    $message .= "Phone:" . $_POST["phone"] . "\n";
                    $message .= "Fax:" . $_POST["fax"] . "\n";
                    $message .= "E-mail:" . $_POST["email"] . "\n";
                    $message .= "Industry Type" . $_POST["IndustryType"] . "\n";
                    $message .= "Other Questions or Comments:" . $_POST["Questions_Comments"] . "\n";
                    
                    // where form_variable_names are the variables the form elements are named
                    
                    // Auto Built
                    
                    $target = $to_email;
                    $additional_headers = 'Return-Path: "' . $from . '" <' . $from_email . 
                    ">\n" . 'From: "' . $from . '" <' . $from_email . ">\n" . 'Reply-To: "' 
                    . $from . '" <' . $from_email . ">\n" . 'X-Mailer: PHP"' . phpversion() 
                    . '"' . "\n" . 'X-From-IP: "' . $user_ip . '"' . "\n";
                    
                    mail( $target, $subject, $message, $additional_headers );
                    
                     ?><?
                    header("Location: http://www.yoursite.com/thankyou.htm");
                    ?>

                      One more quick thing, in the e-mail that I send to the user-- how can I change text in that e-mail to be bold, I.e. names of the fields vs. what a user submits?

                      Also, how do I mark a thread resolved?

                        To style text, you'd need to send HTML e-mails. All you have to do is send the "Content-Type: text/html" header, and then you can use HTML tags (e.g. <b>) to style your text.

                        As my sig explains, there's a link under Thread Tools to mark threads resolved.

                          Can you re-post my code with this new header placed in the correct position? I want to make sure it will send this correctly, my client is already upset that this is not working, I apolgize

                            Just add it to the end of your $additional_headers variable..

                            $additional_headers = 'Return-Path: "' . $from . '" <' . $from_email . 
                            ">\n" . 'From: "' . $from . '" <' . $from_email . ">\n" . 'Reply-To: "' 
                            . $from . '" <' . $from_email . ">\n" . 'X-Mailer: PHP"' . phpversion() 
                            . '"' . "\n" . 'X-From-IP: "' . $user_ip . '"' . "\n" . 'Content-Type: text/html' . "\n"; 
                              Write a Reply...