Thanks to Russell in the subscription forum. I just needed to use the correct hook file name, which is formmail-postconfig.inc.php
Welcome to the Tectite Forums! You can download and get support for our free PHP FormMail (form processor) and other free software.
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 ##
## formmail error ##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$');
The following error occurred in FormMail :
no_valid_recipients
**********
Error=The form has an internal error - no valid recipients were specified.
Thanks to Russell in the subscription forum. I just needed to use the correct hook file name, which is formmail-postconfig.inc.php
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks