+ Reply to Thread
Results 1 to 2 of 2

Thread: dynamic target email

  1. #1
    Join Date
    Jun 2010
    Posts
    9

    Default dynamic target email

    I am using FormMail 8.36 on a PHP page in which the target email is dynamic. After searching the forum, I thought I would try a hook file. The page with the form has the proper dynamic email in the recipient hidden field. I have commented out $TARGET_EMAIL in the formmail file because I have it populating in my hook file (code below). I've tried a few different hook file names in the same folder as formmail without success. The $HOOK_DIR="."; The formmail error sent via email is below.

    ## hook file ##
    PHP Code:
    $id_field = isset($_POST['id_field']) && preg_match('/[A-Z]{4,8}/'$_POST['id_field']) ? $_POST['id_field'] : '';

        require(
    '../includes/dbconn.php');
        
    $query =
        
    "
            SELECT lt.`email`
            FROM the_table AS lt
            WHERE lt.`id_field` = :id_field
        "
    ;
        
    $sth $dbh->prepare($query);
        
    $sth->execute
        
    (
            array
            (
                
    ':id_field' => $id_field
            
    )
        );
        
    $the_email $sth->fetchAll(PDO::FETCH_ASSOC);
        
    $dbh NULL;

    $formatted_email '^'.preg_replace('/\./''\.'strtolower($the_email[0]['email'])).'$';

    $TARGET_EMAIL = array($formatted_email'^someuser@somehost\.ca$'); 
    ## formmail error ##
    The following error occurred in FormMail :
    no_valid_recipients
    **********
    Error=The form has an internal error - no valid recipients were specified.

  2. #2
    Join Date
    Jun 2010
    Posts
    9

    Default Re: dynamic target email

    Thanks to Russell in the subscription forum. I just needed to use the correct hook file name, which is formmail-postconfig.inc.php

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. target email condition
    By spiderling in forum Community Support
    Replies: 4
    Last Post: 08-Mar-2011, 04:14 AM
  2. Dynamic HTML email template problem
    By teeraina in forum Community Support
    Replies: 2
    Last Post: 26-Jan-2011, 10:24 AM
  3. Target Email and Advanced Error Handling
    By PoorSiteCreator in forum Community Support
    Replies: 3
    Last Post: 07-May-2009, 03:58 AM
  4. target email config ?
    By ScottR in forum Community Support
    Replies: 2
    Last Post: 15-Feb-2006, 10:15 PM
  5. dynamic php generated html email not working
    By scrypton in forum FormMail Subscription Support
    Replies: 6
    Last Post: 04-Dec-2005, 12:11 AM

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