Forums

Loading email addresses into bcc

gymrat1964 16 Jan, 2013
I have email addresses that are saved with a registration form into the database. I have another form that I now want to use those emails and import them into the bcc field in the email settings. Any help would be appreciated.
GreyHead 16 Jan, 2013
HI gymrat,

You can use a DB MultiRecord Loader to get them as an array in the $form->data array, then you can put the array name {bcc_array} into the bcc box of my Email [GH] action (it won't work with the standard Email action).

Bob
gymrat1964 16 Jan, 2013
Ok, I used your tutorial on multi record loader, and was able to "display" the email addresses using that on the page. I uploaded your email handler. I'm assuming I use Custom Code to create the array but I'm not sure how to do that.
gymrat1964 16 Jan, 2013
or is this created right in the multi record loader?
GreyHead 17 Jan, 2013
Hi gymrat1964,

I think that if you configure the DB Multi-Record Loader to load just a single column from the table the result will be in an array that you can use. Drag a Debugger action after the DB Multi-Record Loader to see exactly what data you have. Delete the Debugger action again when you are finished with it.

Bob
gymrat1964 17 Jan, 2013
OK, I'm pretty sure that I have everything set up correctly now, but when I hit submit, I am getting the following error - Fatal error: Call to undefined function checkdnsrr() in C:\inetpub\vhosts\talonwebconsulting.com\httpdocs\truelife\administrator\components\com_chronoforms\form_actions\email_gh\email_gh.php on line 404
GreyHead 17 Jan, 2013
Hi gymrat1964,

Oh sorry, thanks for the update, I'll take a look. Are you using Joomla! 3.0? They may have removed the function perhaps.

Bob
gymrat1964 17 Jan, 2013
i'm reading that my PHP version needs to be at least 5.3.0 to support this function, so i have a trouble ticket in with my host to upgrade me. We'll see what that does.
GreyHead 17 Jan, 2013
Hi gymrat1964,

I just found the same thing :-) It was in most PHP versions from v4 but only added to the Windows version in v5.3 from what I see.

If the PHP upgrade doesn't fix it I'll find a way to bypass it.

Bob
gymrat1964 17 Jan, 2013
They say they can't upgrade to 5.3 because of shared hosting on the server.
So I commented out the function and the call to it and the email works fine but it isn't pulling in the array of email addresses. If I put in a static email address, coma, and then {bcclist} it will send to the static address but not the array. Debugger shows
Array
(
[chronoform] => prequest
[event] => submit
[Itemid] => 245
[option] => com_chronoforms
[view] => form
[prayerrequestname] => ron
[prayerrequestemail] => [email]rclayton@co.delaware.oh.us[/email]
[prayerrequest] => testing testing
[chrono_verification] => x5c9k
[input_submit_1] => Submit
[95937658d0a6d7bc431db78bc0b04581] => 1
[IPADDRESS] => 70.60.134.57
)

Validation Errors:

Array
(
)

Debug Data

Email info
Email sent successfully
From: (TLC Marion) [email]ron@talonwebconsulting.com[/email]
Reply to: (ron) [email]rclayton@co.delaware.oh.us[/email]
To: [email]rclayton@co.delaware.oh.us[/email]
BCC: [email]ron@talonwebconsulting.com[/email]
Subject: Request from TLC Website

[attachment=0]config.jpg[/attachment]
gymrat1964 17 Jan, 2013
now that i posted, i think I just saw my mistake. LOL
GreyHead 17 Jan, 2013
Hi gymrat1964,

The Debugger output isn't showing any values for the bcclist array. Either the DB loader isn't producing anything or it isn't running before the Debugger action.

Bob
gymrat1964 17 Jan, 2013
the loader is running "on load" and the debugger is running "on submit"
GreyHead 17 Jan, 2013
Hi gymrat1964,

You need them both in the On Submit event.

Bob

PS You can pass data from the On Load to the On Submit event by adding it to the form in hidden inputs or saving it to the User session but I don't think that is necessary here.
gymrat1964 17 Jan, 2013
Good news is it is populating the array now. Bad news is that it still is not showing up in the bcc field.

[bcclist] => Array
(
[0] => Array
(
[prayeremail] => [email]ron@talonwebconsulting.com[/email]
)

[1] => Array
(
[prayeremail] => [email]ron@sensiblecreative.com[/email]
)

)


Validation Errors:

Array
(
)

Debug Data

db_multi_record_loader
SELECT `prayeremail` FROM `tlc_chronoforms_data_prayersignup` AS `bcclist`
gymrat1964 17 Jan, 2013
Just out of curiosity I tried to use the array in both the cc field and the To field and it didn't work in either case
GreyHead 18 Jan, 2013
Hi gymrat1964,

Yes, what you have is an array of arrays of email addresses. It needs a little work. Add a custom code action between the DB Multi-Record Loader and the Email [GH] action with code like this in it:
<?php
$temp = array();
foreach ( $form->data['bccemail'] as $v ) {
  $temp[] = $v['prayeremail'];
}
$form->data['bccemail'] = $temp;
?>


Bob
gymrat1964 18 Jan, 2013
YOU ROCK. Thank you, working great.
This topic is locked and no more replies can be posted.