Batch emailing [Solved]
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
sorry i meant to add the batchSend
What errors are there
why do you keep saying this when php doesnt say there are any?
Code: Select all
<?
error_reporting(E_ALL);
ini_set("display_errors", "On");
if(isset($_POST['s1']))
{
if(empty($_POST['subject']) || empty($_POST['mm']))
{
echo "<br><center><font color=red size=2 face=verdana><b>All fields are required!</b></font></center>";
}
else
{
//get the users list
$q1 = "select * from dd_newsletter";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) > '0')
{
//Load in the components
require('../../Swift/Swift.php');
require('../../Swift/Swift/Connection/SMTP.php');
//Instantiate swift
$swift = new Swift(new Swift_Connection_SMTP('localhost'));
$subject = $_POST['subject'];
$msg=$_POST['mm'];
$msg=str_replace("\\", "", $msg);
$i=0;
//Create the message
$message =& new Swift_Message($subject);
$message->attach(new Swift_Message_Part($msg, "text/html"));
$to=& new Swift_RecipientList();
while($a1 = mysql_fetch_array($r1))
{
$to->addTo($a1[nemail]);
$i++;
}
//The number of successful recipients is returned here (hopefully 3!)
$number_sent = $swift->batchSend($message, $to, "test@petsupplyuk.com");
echo $number_sent;
if(empty($i))
{
$i = "0";
}
echo "<br><center>$i messages was sent</center>";
}
}
}
?>
<br>
<form method=post>
<table align=center width=340>
<tr style="background-color:#B0B0B0; color:white; font-weight:bold">
<td align=center>Newsletter' Subject Line:</td>
</tr>
<tr>
<td align=center><input type=text name=subject size=41></td>
</tr>
<tr style="background-color:#B0B0B0; color:white; font-weight:bold">
<td align=center>Message:</td>
</tr>
<tr>
<td align=center><textarea cols=39 rows=10 name=mm></textarea></td>
</tr>
<tr>
<td align=center>
<input type=submit name=s1 value=Send>
</td>
</tr>
</table>
</form>What errors are there
why do you keep saying this when php doesnt say there are any?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
is it 8M
http://www.i-db.co.uk/infofromclient.htm - not the same server just the php output i saved.
It keeps asking me to download it when tried a 1000 emails so its the server.
Any ideas?
Thanks for your help
http://www.i-db.co.uk/infofromclient.htm - not the same server just the php output i saved.
It keeps asking me to download it when tried a 1000 emails so its the server.
Any ideas?
Thanks for your help
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
kingconnections
- Forum Contributor
- Posts: 137
- Joined: Thu Jul 14, 2005 4:28 pm
So I don't know about your mail server, but on my servers I don't allow that many email to be sent out in that timeframe.
So for all my scripts like this one I do the follow format .... example:
send 100
sleep for some period of time ... I do sleep 300 / 5 minutes
send 100 more
but this all depends on your mail server.
So for all my scripts like this one I do the follow format .... example:
send 100
sleep for some period of time ... I do sleep 300 / 5 minutes
send 100 more
but this all depends on your mail server.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Try this:
Code: Select all
//Load in the components
require('../../Swift/Swift.php');
require('../../Swift/Swift/Connection/SMTP.php');
require('../../Swift/Swift/Plugin/AntiFlood.php');
//Instantiate swift
set_time_limit(0);
$swift = new Swift(new Swift_Connection_SMTP('localhost'));
//Close the connection, wait 20 seconds, then re-open the connection every 100 emails
$swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 20));
//rest of script- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Hi,
Yes i know the worst thing is having no error message to work on just page canot be dispalayed or download
full code just the testing one real one will be out a database
it sends individual emails on each loop will AntiFlood not work like this
the tests have just been a few letters what about when i start sending full html its not going to do it is it?
thanks
reece
Yes i know the worst thing is having no error message to work on just page canot be dispalayed or download
full code just the testing one real one will be out a database
it sends individual emails on each loop will AntiFlood not work like this
Code: Select all
<?
set_time_limit(0);
error_reporting(E_ALL);
ini_set("display_errors", "On");
if(isset($_POST['s1']))
{
if(empty($_POST['subject']) || empty($_POST['mm']))
{
echo "<br><center><font color=red size=2 face=verdana><b>All fields are required!</b></font></center>";
}
else
{
require('../../Swift/Swift.php');
require('../../Swift/Swift/Connection/SMTP.php');
require('../../Swift/Swift/Plugin/AntiFlood.php');
//Instantiate swift
$swift = new Swift(new Swift_Connection_SMTP('localhost'));
//Close the connection, wait 20 seconds, then re-open the connection every 100 emails
$swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 20), "anti-flood");
$subject = $_POST['subject'];
$msg=$_POST['mm'];
$msg=str_replace("\\", "", $msg);
$i=0;
//Create the message
$message =& new Swift_Message($subject);
$message->attach(new Swift_Message_Part($msg, "text/html"));
while($i<400)
{
if (!$swift->send($message, "............@hotmail.com", "test@..........com")) echo "Failed";
$i++;
}
if(empty($i))
{
$i = "0";
}
echo "<br><center>$i messages was sent</center>";
}
}
?>
<br>
<form method=post>
<table align=center width=340>
<tr style="background-color:#B0B0B0; color:white; font-weight:bold">
<td align=center>Newsletter' Subject Line:</td>
</tr>
<tr>
<td align=center><input type=text name=subject size=41></td>
</tr>
<tr style="background-color:#B0B0B0; color:white; font-weight:bold">
<td align=center>Message:</td>
</tr>
<tr>
<td align=center><textarea cols=39 rows=10 name=mm></textarea></td>
</tr>
<tr>
<td align=center>
<input type=submit name=s1 value=Send>
</td>
</tr>
</table>
</form>the tests have just been a few letters what about when i start sending full html its not going to do it is it?
thanks
reece