PHP mail function problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gggram2000
    New Member
    • Nov 2007
    • 97

    PHP mail function problems

    Hi Im new to this mail function. I have an html page with textboxes, comboboxes and textarea...i've d named them all and created this php sendmail.php file to send all the data. The only thing is when i click on submit I get this error:
    Code:
    Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\sendmail.php on line 12
    My php code is this:
    Code:
    <?php
    
      $Companies = $_REQUEST['Companies'] ;
      $FirstName = $_REQUEST['FirstName'] ;
      $LastName = $_REQUEST['LastName'] ;
      $District = $_REQUEST['District'] ;
      $email = $_REQUEST['email'] ;
      $phone = $_REQUEST['phone'] ;
      $Issues = $_REQUEST['Issues'] ;
      $message = $_REQUEST['message']
      
      mail( "gmedrano@bowen.bz", "Feedback Form Results",
        "$Companies\n $message\n",
    	 "From: $FirstName <$email>" );
      header( "Location: http://localhost/itsuccess.html" );
    ?>
    Im not sure if that is how u set up the data...i'ved searched some tutorials and it just shows the $email and $message variables. All the names are correct, my php.ini settings are as follows:
    Code:
    SMTP = localhost
    smtp_port = 25
    with the other settings not active.

    I'll appreciate any input on this matter...
  • nomad
    Recognized Expert Contributor
    • Mar 2007
    • 664

    #2
    Originally posted by gggram2000
    Hi Im new to this mail function. I have an html page with textboxes, comboboxes and textarea...i've d named them all and created this php sendmail.php file to send all the data. The only thing is when i click on submit I get this error:
    Code:
    Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\sendmail.php on line 12
    My php code is this:
    Code:
    <?php
     
    $Companies = $_REQUEST['Companies'] ;
    $FirstName = $_REQUEST['FirstName'] ;
    $LastName = $_REQUEST['LastName'] ;
    $District = $_REQUEST['District'] ;
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'] ;
    $Issues = $_REQUEST['Issues'] ;
    $message = $_REQUEST['message']
     
    mail( "gmedrano@bowen.bz", "Feedback Form Results",
    "$Companies\n $message\n",
    	 "From: $FirstName <$email>" );
    header( "Location: http://localhost/itsuccess.html" );
    ?>
    Im not sure if that is how u set up the data...i'ved searched some tutorials and it just shows the $email and $message variables. All the names are correct, my php.ini settings are as follows:
    Code:
    SMTP = localhost
    smtp_port = 25
    with the other settings not active.

    I'll appreciate any input on this matter...
    Hello gggram2000
    On line 12 is might look like this...
    [PHP]
    $EmailTo = "gmedrano@bowen .bz;
    [/PHP]
    if you want "Feedback Form Results" you could do this
    [PHP]$EmailFrom = "Feedback Form Results";[/PHP]

    hope that help you...

    nomad

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Why not terminate line 10[php]$message = $_REQUEST['message']
      [/php]with a semi-column?

      Ronald

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Originally posted by ronverdonk
        Why not terminate line 10[php]$message = $_REQUEST['message']
        [/php]with a semi-column?

        Ronald
        Yeah, that would be the problem.

        Comment

        • gggram2000
          New Member
          • Nov 2007
          • 97

          #5
          Yea thanks I was missing that...Now I get this error:
          Code:
          Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\sendmail.php on line 15
          
          Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\sendmail.php:15) in C:\xampp\htdocs\sendmail.php on line 16
          The SMPT and SMTP port are set properly...I've d done all sort of changes and it still gives me the same error...Any suggestions?

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            Firstly: the second error is only issued because of the display of the first error.

            I do not think you have configured your setting correctly in php.ini. You specify
            Code:
            SMTP=localhost
            but have you really installed an SMTP server on your localhost? If not, then specify a smtp server (e.g. the one of your ISP).

            Ronald

            Comment

            • gggram2000
              New Member
              • Nov 2007
              • 97

              #7
              Originally posted by ronverdonk
              Firstly: the second error is only issued because of the display of the first error.

              I do not think you have configured your setting correctly in php.ini. You specify
              Code:
              SMTP=localhost
              but have you really installed an SMTP server on your localhost? If not, then specify a smtp server (e.g. the one of your ISP).

              Ronald
              Thanks, I realized I had four php.ini files and it seems that it was picking up the one in XAMPP and not the one on windows. Also you were right about the localhost, I specified the smtp server and it worked great.

              Cheers!

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                Glad it is solved. See you around.

                Ronald

                Comment

                • badvoc
                  New Member
                  • Sep 2007
                  • 44

                  #9
                  Hi

                  Just thought I say thanks as this has helped me. I had my sales email address in the mail header and found some emails have been going in to spam boxes and therefore missed. I now have the comany name in from field.

                  Always the first port of call for help and never failed me yet!!!

                  Thanks again.

                  Comment

                  Working...