Send email based on an element

smkso

New Member
Hi,

I'm not sure is the title is correct to explain my problem. Here it goes,

I want to send email if the element is set to a certain record.

I have an element named 'Status'. If 'Status' is set to 'Pending' then an email will be sent, if 'Status' is set to 'Completed' then the email will not be sent.

I know that there is an option named 'Email to (eval)' but I'm not sure how to code this.

Help! Thanks in advance!
 
I tried this after looking at a thread which kind of similar to mine, but it doesnt work.

PHP:
$db =& JFactory::getDBO();
$recipient = '{emailtest___email}';
$status = '{emailtest___status_raw}';
 
if ($status == 'pending')
{
    $query = "SELECT `email` FROM `emailtest` WHERE `id` = " . $db->Quote($recipient);
    $db->setQuery($query);
    $result = $db->loadResult();
    return $result;
}
else {
    return "test@gmail.com";
};
 
Just an update, I think I solved this problem;
PHP:
$recipient = '{emailtest___email}';
$status = '{emailtest___status_raw}';
 
if ($status == 'pending')
{
    return $recipient;
}
else {
    return false;
};

its that simple!
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top