[OK] Multiple email receiver one by one from a list

ckforall 21 Mar, 2009
Hi all,

I would to know if it's possible to create a portion of code (php), directly with this mod, to publish results of a form by email to a list of users and, it's important, one by one ( i mean like a rotate receiver) so :

receiver are : one, two, three, etc.

form result 1 to -> user one (we store result)
next, using form,
form result 2 to -> user two (we store result )

ETC... 'till the end of the list ...

it 's for commercial service and the idea is to use this tools to create a contact form like a "rotate" contact destination...

I don't know if it's clear so sorry my english is not full ๐Ÿ˜ถ

Tks for your reply

CK
GreyHead 21 Mar, 2009
Hi ck,

Yes I think you could do this. You'd need to make sure that you emailed links to the form that identifed the next user but that could be done ok.

May not be simple, but is possible,

Bob
ckforall 21 Mar, 2009
hi bob,

tks for your reply ๐Ÿ˜€

Thank you for this excellent answer, but I did not catch the deep meaning (joke).

So, you're right, the important thing is to know that it can do it but, my next questions are...

HOW to

or the other one is

Where

i know it's heavy ๐Ÿ˜ถ , but actually i would like to have a little tips :wink:

Or may be it's possible with the pro version ? (or feature ?) (please let me dream on it๐Ÿ™‚ )

otherwise, no problem, I will find another solution with a distribution list...

Great job
sincerely
GreyHead 22 Mar, 2009
Hi Ck,

I can help you with ChronoForms but I can't build your application for you (at least not for free in the forums).

To test this out, build a simple version. Create a form with a couple of fields and a submit button. Decide where your name list is and how you are going to store the information.

Then come back with the next question please.

Bob
ckforall 22 Mar, 2009
Hi again GreyHead,

Just a little feedback ๐Ÿ™‚

I've done it ๐Ÿ˜€ and if it could be help someone i post it here so :

First we need to have a "Dynamic To" field for receiver and this one should point to the hidden field in the email templates.
(for example my hidden field name destinator_14)

I put the code below @ -> form code tab in -> "on submit code section" -> (from the admin panel) :

<?php

global $db;
// define if not (to select the default key)
	if (!isset($_SESSION['__CK']['numcurrent'])) {
		$cknumcur = 0;
		} else {
		$cknumcur = $_SESSION['__CK']['numcurrent'];
	}

// reset data from array  
	 $_SESSION['__CK']['data']='';

// store new data to array $muuseractif1
	$db =& JFactory::getDBO();
	$sql= "SELECT * FROM user_to_rotate";
	$db->setQuery( $sql ); 
	$muuseractif1 = $db->loadObjectList();
	$_SESSION['__CK']['data'] = $muuseractif1;

// Section to get key first and last of __CK.data array
$tdumm = $_SESSION['__CK']['data'];
ksort($tdumm);
$firstkey = key($tdumm);
krsort($tdumm);
$lastkey = key($tdumm);

// if we R under the last number of array key we add one more since under the last
if ($cknumcur < $lastkey) {
$cknumcur++;
} else {
$cknumcur=0;
}
// reset the numcurrent var (loop to 0 if the end)
$_SESSION['__CK']['numcurrent']= $cknumcur;

// update the actif state of user
$sql2 =  "UPDATE  user_to_rotate SET  actif = '1' WHERE numuse = ".$_SESSION['__CK']['data'][$cknumcur]->numuse."";
$db->setQuery( $sql2 ); 
$db->loadObjectList();
$sql2 =  "UPDATE  user_to_rotate SET  actif = '0' WHERE numuse <> ".$_SESSION['__CK']['data'][$cknumcur]->numuse."";
$db->setQuery( $sql2 );
$db->loadObjectList();

// to set up the destinator of email and customize a little bit more the email template with the name of receiver
$_POST['destinator_14'] = $_SESSION['__CK']['data'][$cknumcur]->email;
$_POST['destinatorname_15'] = $_SESSION['__CK']['data'][$cknumcur]->name;
?>


(the code below is not optimize but don't have a lot of time ๐Ÿ˜ถ )

The table name is : user_to_rotate
(important to store the list of receiver with id, name, email and state (activ(f) or not)
And the content of this table is :


--
-- Structure de la table `user_to_rotate`
--

CREATE TABLE IF NOT EXISTS `user_to_rotate` (
  `numuse` int(11) NOT NULL auto_increment,
  `name` varchar(200) NOT NULL,
  `email` varchar(200) NOT NULL,
  `actif` int(1) NOT NULL default '0',
  PRIMARY KEY  (`numuse`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

--
-- Contenu de la table `user_to_rotate`
--

INSERT INTO `user_to_rotate` (`numuse`, `name`, `email`, `actif`) VALUES
(1, 'user1', 'user1@fake1.com', 0),
(2, 'user2', 'user2@fake2.com', 0),
(3, 'user3', 'user3@fake3.com', 1),
(4, 'user4', 'user4@fake4.com', 0);


(you can add more record if you want (directly with phpmyadmin ๐Ÿ™„ ))
In the email template i add {destinatorname_15} tag to customize the template like "good day brian"
In -> form code tab and -> form html section -> i add 2 hidden field @ the end of code like :

<input value="none" id="hidden_14" name="destinator_14" type="hidden" />
<input value="none" id="hidden_15" name="destinatorname_15" type="hidden" />


first is important (setting the email adresse to receiver) by changing the post var (see above in the php code)
second is optionnal to customize the email template (see above) (same by changing the post var)

Now it's ok, each time the form is submit the receiver is changing whithout break this famous mod code๐Ÿ™‚
submit 1 receiver is -> user1,
submit 2 receiver is -> user2,
submit 3 receiver is -> user3,
eTC.


Tks for your participation GreyHead and your excellent mod
i hope it could be help someone else๐Ÿ™‚

And Voilร  :wink:
GreyHead 22 Mar, 2009
Hi ckforall,

Well done, looking good !!

Bob
This topic is locked and no more replies can be posted.