SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: email directing

  1. #1
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    email directing

    I'm still new to this stuff and am trying to get an email sent out from a form depending on subject line. If subject is somthing it goes to one email address if it is something else it goes to another and so on. I have read and tried different ideas out of the PHP and MySQL web development book but cant get it to work. Can anyone offer any suggestions and tips on what i'm doing wrong. Thanks.
    Pat
    Here is sort of what i have
    #######################
    if ($subject == 'request')
    $toaddress = 'csd@bluegrassmountain.com';
    //else if ($subject == 'missy')
    //$toaddress = 'dee@patndee.com';
    //else if ($subject == 'cds')
    //$toaddress = 'orders@bluegrassmountain.com';
    //else if ($subject == 'bookings')
    //$toaddress = 'missy@bluegrassmountain.com';
    else $toaddress = 'pat@patndee.com'; //default email
    $subject = $_POST["messagetype"];
    $mailcontent = 'Customer name: '.$name."\n"
    .'Customer email: '.$email."\n"
    .'Contact requested: '.$contactrequested."\n"
    .'Department: '.$department."\n"
    ."Customer requests or comments: \n".$request."\n";

    $fromaddress = 'From: contacts@bluegrassmountain.com';

  2. #2
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $subjects = array(
                     
    "request",
                     
    "missy",
                     
    "cds",
                     
    "bookings"
                     
    );

    $toaddresses = array(
                         
    "csd@bluegrassmountain.com",
                         
    "dee@patndee.com",
                         
    "orders@bluegrassmountain.com",
                         
    "missy@bluegrassmountain.com"
                          
    );

    $toaddress 'pat@patndee.com'//default email

    $subject $_POST["messagetype"];
    for(
    $i=0$i<count($subjects); $i++){
         if(
    strcasecmp($subject,$subjects[$i])==0){
              
    $toaddress $toaddresses[$i];
              break;
         }
    }

    $mailcontent 'Customer name: '.$name."\n"
    .'Customer email: '.$email."\n"
    .'Contact requested: '.$contactrequested."\n"
    .'Department: '.$department."\n"
    ."Customer requests or comments: \n".$request."\n";

    #$fromaddress = 'From: [email]contacts@bluegrassmountain.com[/email]';
    $fromaddress 'contacts@bluegrassmountain.com';
    $sent = @mail($toaddress,$subject,$mailcontent,"From: Contact <$fromaddress>\r\n"); 
    Cheers!

  3. #3
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getting a Parse error: parse error, unexpected $ in /home/www/bluegrassmountain/missy/contact.php on line 181
    all that is close to that line is my closing include footer
    ##################
    <div class="fieldContainer1">
    <input name="submit_form" type="Submit" value="Submit Form">
    <input type="reset" value="Clear Form">
    </div>
    </fieldset>
    </form>
    <br>
    </div></div>
    </div>
    <?php
    require ('./inc/footer.inc.php');
    ?>
    here is the first part of the script. I dont want to flood or make it longer than i have to so i will attempt to keep it short
    Pat
    ###################
    <?php
    if(isset($_POST['submit_form'])) {
    # Default error_header
    $error_header = "<p>Please check below for the errors that have occured, Pease be sure to include the missing fields indicated before continueing</p><br>";

    # error checking
    if(!$_POST['name']) {
    $error1 = '<p>Please Fill in the Name field</p>';
    } /*check to make sure name is filled in, if not display error message on form as error1*/
    if(!$_POST['email']) {
    $error2 = '<p>Please fill in the email field</p>';
    } /*check to make sure email is filled in, if not display error message on form as error2*/

    if(!$_POST['request']) {
    $error3 = '<p>Please fill in your request or comments</p>';
    } /*check to make sure a suggestion is filled in, if not display error message on form as error3*/
    if ($_POST['department'] == 'none') {
    $error4 = '<p>Please select an area you would like to comment on<p/>';
    }
    if ($_POST['contactrequested'] == 1) $contactrequested = "Please contact me";
    if(!$error1 && !$error2 && !$error3 && !$error4)
    $subjects = array(
    "request",
    "missy",
    "cds",
    "bookings",
    "coments",
    "web-site",
    "fan-club"
    );
    $toaddresses = array(
    "csd@bluegrassmountain.com",
    "missy@bluegrassmountain.com",
    "orders@bluegrassmountain.com",
    "missy@bluegrassmountain.com",
    "csd@bluegrassmountain.com",
    "pat@patndee.com",
    "dee@bluegrassmountain.com"

    );
    $toaddress = 'pat@patndee.com'; //default email
    $subject = $_POST["messagetype"];
    for($i=0; $i<count($subjects); $i++){
    if(strcasecmp($subject,$subjects[$i])==0){
    $toaddress = $toaddresses[$i];
    break;
    }
    }
    $mailcontent = 'Customer name: '.$name."\n"
    .'Customer email: '.$email."\n"
    .'Contact requested: '.$contactrequested."\n"
    .'Department: '.$department."\n"
    ."Customer requests or comments: \n".$request."\n";
    #$fromaddress = 'From: contacts@bluegrassmountain.com';
    $fromaddress = 'contacts@bluegrassmountain.com';
    $sent = @mail($toaddress,$subject,$mailcontent,"From: Contact <$fromaddress>\r\n");

    ?>
    <?php
    require ('./inc/header.inc.php');
    ?>


    This is part of the form i'm trying to use
    #######################
    <fieldset class="subject">
    What kind of request or comment would you like to send us?<br>
    <span>
    <input id="request" value="request" name="messagetype" type="radio" />
    <label for="request">Special-request</label></span>
    <span>
    <input id="missy" value="missy" name="messagetype" type="radio" />
    <label for="Missy">Missy</label></span>
    <span>
    <input id="Bookings" value="bookings" name="messagetype" type="radio" />
    <label for="bookings">Bookings</label></span><br>
    <span>
    <input id="cds" value="CDs" name="messagetype" type="radio" />
    <label for="cd's">CD's</label></span>
    <span>
    <input id="comment" value="comment" name="messagetype" type="radio" />
    <label for="comment">Comments </label></span>
    <span>
    <input id="website" checked value="website" name="messagetype" type="radio" />
    <label for="Website">Web-site </label></span>
    <span>
    <input id="fan-club" checked value="fan-club" name="messagetype" type="radio" />
    <label for="Website">Fan Club</label></span>
    </fieldset>
    can anyone tell me what I'm missing to get this form to email the right person based on subject chosen
    Pat

  4. #4
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where's line 81?

  5. #5
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is line 177 to 183. 183 is the very last line I hope you are able to help me out with this is sure would be nice to have the email directed based on subject or department
    Pat
    ###############
    </form>
    <br>
    </div></div>
    </div>
    <?
    require ('./inc/footer.inc.php');
    ?>
    ########################
    this is line 75 to 84
    ##################

    <?php
    require ('./inc/header.inc.php');
    ?>
    <div id="contentinner1">
    <!--centre content goes here -->
    <div id="innertop">
    <div id="contactinfo">
    <h1>Missy's contact page<br>C/O Bluegrassmountain.com</h1>
    <ul>
    <li><span>Address/span><br>


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
  •