Email Plugin - sent email to recipient from different list

verzevoul

Member
Goodmorning to all!
I succeded to send mail after form is submitted to 2 email, with placeholder.
My problem is that I can' t make it work for another form with recipients belonging to another list.
In the field "Email to", what is the syntax of placeholder to correctly include an element from another list?
I also tried

$query = "SELECT `email` FROM `aaatickets` WHERE `id` = '{aaatickets___email_raw}'";

but It doesn t work. I saw it from a post.
 

Attachments

  • working.jpg
    working.jpg
    78.3 KB · Views: 163
This statement should live in the eval section of the email plugin.

You will need:
$db=&JFactory::getDBO();
$query= ... your query
$db->setQuery($query);
$data = $db->loadObject();
return $data->email;

Should work for you.
 
is my syntax ok? I doesn t save in db

$db=&JFactory::getDBO();
$db-> setQuery("SELECT `email` FROM `j25_users` WHERE j25_users.`id` in (SELECT pelatis FROM `aaatickets` join `aaaapantiseis2` on `aaaapantiseis2`.`join_id`=`aaatickets`.`id`
where `aaaapantiseis2`.join_id=36)");
$data = $db->loadResult();
return $data->email;
 
loadResult() contains the first field of the first row, so only do
return $data;

or as achartier says
$data = $db->loadObject();
return $data->email;

Do you expect only one row/email?
 
Two things ... loadObject() only loads the first row of the result set. And the "Email to eval" expects you to return a comma separated list of addresses, not an object or an array.

So you'd need to do something like ...

PHP:
$results = $db->loadObjectList();
$emails = array();
foreach ($results as $result) {
    $emails[] = $result->email;
}
return implode(',', $emails);

-- hugh
 
Thanks!

I xpect one result from the query, and it not coming.
So I created a calc element in my list that runs the query and I entered in my form email plugin
{aaaapantiseis2___email_join_apantisi},info@.....gr, in email to filed.
It should work like this.
But again the query doenst store anything in
email_join_apantisi_raw which is my calc element. My calc element is


--------------------------
$emailaki = {aaaapantiseis2___join_id_raw};

$db=&JFactory::getDBO();
$db-> setQuery("SELECT `email` FROM `j25_users` WHERE j25_users.`id` in (SELECT pelatis FROM `aaatickets` join `aaaapantiseis2` on `aaaapantiseis2`.`join_id`=`aaatickets`.`id`
where `aaaapantiseis2`.join_id=36)");
$data = $db->loadObject();
return $data->email;
--------------------------
I wrote 36 as and not $emailaki because 36 I m sure it exist.
My github is... look jpg
 

Attachments

  • version.jpg
    version.jpg
    347.2 KB · Views: 155
SELECT `email`
FROM `j25_users`
WHERE j25_users.`id`
IN (

SELECT pelatis
FROM `aaatickets`
JOIN `aaaapantiseis2` ON `aaaapantiseis2`.`join_id` = `aaatickets`.`id`
WHERE `aaaapantiseis2`.join_id =36
)

returns result as expected
 
1. you always should quote placeholders, so you won't get a PHP error if the field is emtpy (or not a number), so
$emailaki = '{aaaapantiseis2___join_id_raw}';

2. for debugging (you can do it in the calc element and in the email plugin eval)
PHP:
$emailaki = '{aaaapantiseis2___join_id_raw}'; 

$db=&JFactory::getDBO();
$query="SELECT `email` FROM `j25_users` WHERE j25_users.`id`  in (SELECT pelatis  FROM `aaatickets`  join `aaaapantiseis2` on   `aaaapantiseis2`.`join_id`=`aaatickets`.`id`
where `aaaapantiseis2`.join_id=36)";
$db-> setQuery($query);

$data = $db->loadObject();

var_dump($emailaki,$query,$data);exit;

return $data->email;
This will give you a blank page showing the content of your variables.
Set Joomla error reporting to maximum.
 
I dont want to offend you but you didn t reply to my question.

is that query ok?
------------------------------------------------------------------
$db=&JFactory::getDBO();
$db-> setQuery("SELECT `email` FROM `j25_users` WHERE j25_users.`id` in (SELECT pelatis FROM `aaatickets` join `aaaapantiseis2` on `aaaapantiseis2`.`join_id`=`aaatickets`.`id`
where `aaaapantiseis2`.join_id=36)");
$data = $db->loadObject();
return $data->email;
-------------------------------------------------------------
because in phpmyadmin it returns result if I run it.
But from a calc element it doesn t store anything.
So I suppose there is a syntax error on how I write it im my calc element
 
- did you use the var_dump for debugging?

- the value returned by a calc element is only stored in the database if you (re)-save your record. So if you add a calc element to an existing list/table the value will be initially NULL in all existing record.

- if you use the code in the email eval there won't be anything stored in the DB
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top