The Joomla! Forum ™






Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon May 02, 2011 5:21 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Apr 07, 2011 6:55 am
Posts: 6
Location: Zimbabwe
l am trying to send an email to a list in batches of 50.

The problem is when l get the emails from the database and then loop through sending emails l experience email bombarding i.e l get about 12 emails to one emails.


Top
 Profile  
 
PostPosted: Mon May 02, 2011 8:13 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Sun Sep 05, 2010 7:33 am
Posts: 57
Very weird thing.You can provide the part of php code you use to make this sending e-mails loop ?
Can be something wrong there.

_________________
Joomla! Extensions
http://www.beesto.com


Top
 Profile  
 
PostPosted: Tue May 03, 2011 7:58 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Apr 07, 2011 6:55 am
Posts: 6
Location: Zimbabwe
l have got something like below.
$sql = SELECT `email` FROM `#__members` WHERE `premium` = '1' LIMIT 50
$db->setQuery($sql);
$res = $db->loadObjectList();
//l import the mailer here
foreach($res as $r)
{
$emailto = $r->email;
then l send the email here using Jutility::Sendmail()
}
l skipped the actuall code because l know the code is correct so l just gave the logic l am following


Top
 Profile  
 
PostPosted: Tue May 10, 2011 8:41 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Apr 07, 2011 6:55 am
Posts: 6
Location: Zimbabwe
function sendRequests()
{
$db = & JFactory::getDBO();
$sql = "SELECT *
FROM `#__quotehunter_hunt_quotes`
WHERE `flag` = '0'
LIMIT 1";
$db->setQuery($sql);
$quotereq = $db->loadObject();
if (count($quotereq) == 0)
{
exit();
}
$site = JURI::Root();
$body = '<html>
<head>
<title>
Your Free Email
</title></head><body><table align="center" width="600" style="font-family: Arial; color: #666666; font-size: 12px; border: 1px solid #e5e5e5; background: #E8F5E6;">';
$body .= '<tr>
<td colspan="4">' . $image . '</td>
</tr>';
$body .= '<tr>
<td colspan="4" style="color: #666666; border: 1px solid #e5e5e5; border-spacing: 1px;"><h4 style="font-family: Tahoma">PLEASE FIND BELOW DETAILS OF A REQUEST FOR QUOTE IN ONE OF THE CATEGORIES YOU HAVE AN ENTRY</h4></td>
</tr>';
$body .= '<tr>
<td style="background: #666666; color: #000000; border: 1px solid #e5e5e5; border-spacing: 1px;">Contact Person</td>
<td style="background: #666666; color: #000000; border: 1px solid #e5e5e5; border-spacing: 1px;">Company</td>
<td style="background: #666666; color: #000000; border: 1px solid #e5e5e5; border-spacing: 1px;">Email Address</td>
<td style="background: #666666; color: #000000; border: 1px solid #e5e5e5; border-spacing: 1px;">Due Date</td>
</tr>';
$body .= '<tr>
<td style="color: #666666; border: 1px solid #e5e5e5; border-spacing: 1px;">' . $quotereq->name . '</td>
<td style="color: #666666; border: 1px solid #e5e5e5; border-spacing: 1px;">' . $quotereq->company . '</td>
<td style="color: #666666; border: 1px solid #e5e5e5; border-spacing: 1px;">' . $quotereq->email . '</td>
<td style="color: #666666; border: 1px solid #e5e5e5; border-spacing: 1px;">' . $quotereq->due_date . '</td>
</tr>';
$body .= '<tr>
<td colspan = "4" style="background: #666666; color: #000000; border: 1px solid #e5e5e5; border-spacing: 1px;">Specific Requirements</td>
</tr>';
$body .= '<tr>
<td colspan="4" style="color: #666666; border: 1px solid #e5e5e5; border-spacing: 1px;">' . $quotereq->wanted . '</td>
</tr>';
$body .= '</table></body></html>';
$body .='<p> Submitted From ' . $_SERVER['REMOTE_ADDR'] . '</p>';
//get last id in case of more than 500
$latstitem = QuoteHunterHelper::getResult('#__quotehunter_temp', 'quote');
$sql1 = "SELECT `itemid` FROM `#__sobi2_cat_items_relations` WHERE `catid` = '$quotereq->category' AND `itemid` > '$latstitem' LIMIT 50";
$db->setQuery($sql1);
$comps = $db->loadObjectList();
if (count($comps) == 0)
{
QuoteHunterHelper::genericUpdate('#__quotehunter_temp', 'quote', 0);
$this->updateFild('#__quotehunter_hunt_quotes', 'id', $quotereq->id, 'flag', '1');
exit();
}
foreach ($comps as $comp)
{
$item = $comp->itemid;
$sql2 = "SELECT DISTINCT(`data_txt`) FROM `#__sobi2_fields_data` WHERE `fieldid` = '7' AND `itemid` = '$item'";
$db->setQuery($sql2);
$emailto = $db->loadResult();
QuoteHunterHelper::dispatchEmail($emailto,$body);
}
QuoteHunterHelper::genericUpdate('#__quotehunter_temp', 'quote', $item);
exit();
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 



Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group