Page 2 of 2

Posted: Thu Feb 22, 2007 12:09 pm
by Chris Corbyn
Pardon? batchSend(). You *still* have problems with your code :?

Posted: Thu Feb 22, 2007 12:34 pm
by reecec
sorry i meant to add the batchSend

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?

Posted: Thu Feb 22, 2007 12:41 pm
by Chris Corbyn
Your host must have ini_set() disabled. You have notices, not errors. You've still got places where you're not enclosing strings with quotes.

Can you PM what your phpinfo() says?

Posted: Thu Feb 22, 2007 12:48 pm
by reecec
yes i have noticed there notices which i don't get on my server i don't think

is this the error setting in php info

display_errors On On

Posted: Thu Feb 22, 2007 12:59 pm
by Chris Corbyn
And also error_reporting will have a numeric value. I was actually more curious what your host have their memory_limit set to.

Posted: Fri Feb 23, 2007 9:38 am
by reecec
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

Posted: Fri Feb 23, 2007 1:46 pm
by Chris Corbyn
Are you trying to send 1000 emails in one go without any sleeping or anything? 8O 8O 8O 8O 8O 8O

Posted: Fri Feb 23, 2007 2:07 pm
by reecec
yea lol take it thats not right they way you said it.


it just wants me to download the file

thanks

reece

Posted: Fri Feb 23, 2007 2:20 pm
by kingconnections
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.

Posted: Fri Feb 23, 2007 2:28 pm
by Chris Corbyn
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

Posted: Fri Feb 23, 2007 4:42 pm
by reecec
thanks d11wtq for adding directory location for the anti flood file and the code


it decided to try 200 it sent them and then asked me to download the file (firefox dont know if its different it ie) EDIT: Just checked ie paged cannot be displayed

thanks


reece

Posted: Fri Feb 23, 2007 5:36 pm
by Chris Corbyn
Ok, given that this is happening with PHPMailer, and also with Swift Mailer I'm running out of options as to causes, other than a faulty PHP install, or some code elsewhere in your app that you haven't posted.

Posted: Sat Feb 24, 2007 4:23 am
by reecec
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

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

Posted: Sat Feb 24, 2007 6:37 pm
by reecec
Hi

I have decided to use perl and it sends out these emails realy quickly


I think you right its a server issue with php

swift mailer is made really well thanks d11wtq and thanks for you help and anyone else that also helped


Reece