Advanced Search

Results 1 to 3 of 3

Thread: send mail php

  1. #1
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face send mail php

    Can any one help me set up my send mail php script to do what I need it to do? In the form I added 2 more fields called company and phone. As the script is written right now only the name, email and message will show up in the submitted email. I have tried to add the 2 new fields in many ways, but I get an error. Just not doing it right because I am not php savvy. What I want to see in the submitted email is this order:

    Name:
    Company:
    Email:
    Phone:
    Message:

    (the form is in a flash file so can't show you that, but it does work with the php as shown below, just not how I want it to)

    ***************************

    PHP Code:
    <?
    //Send Mail PHP
    //
    //Upload this file to the root of your web directory

    if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_name']))

    {
        
    //Insert Address(s) to send the mail to
        
    $to "dianadolce@gmail.com";

        
    //Subject
        
    $subject "Message from Amadeus Brochure Form";
        
        
    //Body
        
    $body stripslashes($HTTP_POST_VARS['sender_message']);

        
    $body .= "\n---------------------------\n";

        
    $body .= "Mail sent by: " $HTTP_POST_VARS['sender_name'] . " <" $HTTP_POST_VARS['sender_mail']  . ">\n";

        
    $body .= "\n\n";

        
    $body .= "\nservice powered by dhsartstudio.com\n";

        
    $header "From: " $HTTP_POST_VARS['sender_name'] . " <" $HTTP_POST_VARS['sender_mail'] . ">\n";

        
    $header .= "Reply-To: " $HTTP_POST_VARS['sender_name'] . " <" $HTTP_POST_VARS['sender_mail'] . ">\n";

        
    $header .= "X-Mailer: PHP/" phpversion() . "\n";

        
    $header .= "X-Priority: 1";

        
    //Mail Sentinel
        
    if(@mail($to$subject$body$header))

        {
        
    //Return Mail Status to Flash Form
            
    echo "output=sent";

        } else {

            echo 
    "output=error";

        }

    } else {

        echo 
    "output=error";

    }

    ?>
    ***********************

    Thank you, thank you for looking at this and helping me understand what has to happen.

    Diana

    Edit: Wrapped the code in [php][/php] tags
    Last edited by tech_support; 01-11-2008 at 12:22 AM.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    welcome to the forums, and thank you for using a descriptive title.
    Please review our Posting Policies especially in regards to posting computer code within a thread... Rule #8


    //Body
    $body = stripslashes($HTTP_POST_VARS['sender_message']);

    $body .= "\n---------------------------\n";

    $body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";

    $body .= "\n\n";

    $body .= "\nservice powered by dhsartstudio.com\n";
    just add another line to the body to include whatever you call the phone and company and any other additional values

    Code:
    ...
    $body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
    
    $body .= "Phone Number: ". $HTTP_POST_VARS['phone'] ."\n";
    
    $body .= "Company: ". $HTTP_POST_VARS['company'] ."\n";
    
    ...
    That would put the phone and company, but it follows the format of

    Code:
    $body .= "Title: ". $HTTP_POST_VARS['_form_name_element_'] ."\n";
    to explain that
    • $body .= is to initiate contantenate something to the end of the string, in your case the main content section of the email

    • "Title: ". will give the reference to some type of title. Please not that it must be enclosed within quotation marks, as that is part of PHP Syntax.

    • $HTTP_POST_VARS['_form_name_element_'] the name of the element as it appears in the form so for the phone text input form field you would put <input type="text" name="_form_name_element_" value="">

    • ."\n"; create a new line character (character return), so the next instance of the body tag is on a new line.


    if you follow that format you can put as many new elements as you wish.

  3. #3
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Wonderful, I will try that again. I can see where I made a mistake previously trying to do this. We let you know, thanks Boogyman

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •