SendMail Function - Repeats #1 and doesn't cycle
Posted: Wed May 05, 2010 3:37 pm
Hey I'm a newbie here, so if I am posting something unclear I apologize...
I have this function that is supposed to take all the questions that were posted for my therapist which I select and resend them to my designated person. I had 3 questions selected. It sent me the first questions approximately 250 times. Can anyone help me in fixing this to only send the question once, while cycling through the selected questions?
If I can clear anything up for you please let me know. I would like to get this fixed asap and appreciate any and all help.
Thanks,
Brian
I have this function that is supposed to take all the questions that were posted for my therapist which I select and resend them to my designated person. I had 3 questions selected. It sent me the first questions approximately 250 times. Can anyone help me in fixing this to only send the question once, while cycling through the selected questions?
If I can clear anything up for you please let me know. I would like to get this fixed asap and appreciate any and all help.
Thanks,
Brian
Code: Select all
function sendMail()
{
global $mainframe,$option;
$row =& JTable::getInstance('question', 'Table');
$cid = JRequest::getVar('cid', array(), 'array');
for ( $i=0;$i<count($cid);$i++ )
{
$id = $cid[$i];
$row->load($id);
$mailFrom = $mainframe->getCfg('mailfrom');
$fromName = $mainframe->getCfg('fromname');
//$notifiedEmail = explode(',',$notifiedEmail);
$notifiedEmail = 'email@email.com';
$subject = 'New Question posted for the Therapist';
//echo $qId;
$link2Question = JURI::root().'index.php/component/askthetherapist/?view=answer&task=edit_answer&question_id='.$id;
$body = 'A question has been posted for the Therapist. To answer the question click the link and Login.<br/>'
.'<em>The question will not be posted until an answer has been created</em><br/><br/>'
.'<strong>Subject: </strong><a href="'.$link2Question.'">'.$row->title.'</a><br/><br/>'
.'<strong>Question: </strong>'.$row->description.'<br/><br/>'
.'<strong>Email: </strong>'.$row->email;
$config = JComponentHelper::getParams('com_askthetherapist');
$stremail = $config->get('email_therapist');
$arremail = explode(';',$stremail);
for ($i=0;$i<count($arremail);$i++)
{
JUtility::sendMail($mailFrom,$fromName,$arremail[$i],$subject,$body,1);
}
}
$mainframe->redirect('index.php?option='.$option.'&task=showquestion', 'Re-Send question to therapists successfull!');
}