Hello,
I'm verry impressed about the function swift has! I'm trying to implementate it into an newslettersystem, but sending the mails out is verry slow. It does send one mail per second! I have a couple of thousands recipients, so one second per email is a little too much.
But I am not sure or it is swifts fault, can it be that my mailserver only accepts one email per second? What is the avarage amount of emails that is possible to send with swift per second/minute?
Thanks,
Peter
It takes long to sent the mail out
Moderators: Chris Corbyn, General Moderators
Re: It takes long to sent the mail out
I tried another server: It takes one second to send 10 mails
So: It is an server problem...
So: It is an server problem...
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
Re: It takes long to sent the mail out
Make sure you're using the batchSend() function when sending e-mails to a large amount of people at once.
Re: It takes long to sent the mail out
Also, try to benchmark your "application code" by using an empty send() function.
This would show you how "quick" can your application go and so you should be able to see if the problem is on your MySQL queries (the most common problem in performances issues)
This would show you how "quick" can your application go and so you should be able to see if the problem is on your MySQL queries (the most common problem in performances issues)
Re: It takes long to sent the mail out
Josh: I have tried the normal send and the batchSend function, it doesn't matter it takes the same time.
xdecock: How do you mean exactly "an empty send() function"? I've tried
But then I get an catchable fatal error:
This is my test script:
I've done some performance tests, the batchSend function takes one second per email address.
I've asked my webhost the limit of sending emails per second, they told me that the limit is 32 mails/sec inbound and 16 mails/second outbound. This shouldn't be the problem, but how come on my other webhost the same script is well very fast? Could be the reason that this webhost is running windows and IIS and my secondary webhost an linux distrubution with appache running?
xdecock: How do you mean exactly "an empty send() function"? I've tried
Code: Select all
$smtp = new Swift_Connection_SMTP('localhost');
$smtp->setUsername('username');
$smtp->setPassword('password');
$swift = new Swift($smtp);
$swift->send();
$swift->disconnect();
Code: Select all
Catchable fatal error: Argument 1 passed to Swift::send() must be an instance of Swift_Message, none given, called in E:\vhosts\domain.tld\httpdocs\mailing\emptysend.php on line 21 and defined in E:\vhosts\domain.tld\httpdocs\mailing\lib\Swift.php on line 329Code: Select all
<?PHP
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
require_once "lib/Swift/Plugin/Decorator.php";
//Array with the mail addresses
$array[0] = "mail1@domain.tld";
$array[1] = "mail2@domain.tld";
$array[2] = "mail3@domain.tld";
//Instantiate Swift as usual
$smtp = new Swift_Connection_SMTP('localhost');
$smtp->setUsername('username');
$smtp->setPassword('password');
$swift = new Swift($smtp);
//Create the message, using some unique variables to search for
$message =& new Swift_Message("Hey {mail}.", "This is a message for {mail}!");
$recipients =& new Swift_RecipientList();
foreach($array as $value)
{
$replacements = array(
$value => array("{mail}" => $value)
);
$swift->attachPlugin(new Swift_Plugin_Decorator($replacements), "decorator");
$recipients->addTo($value);
}
//Send messages
$swift->batchSend($message, $recipients, new Swift_Address("email@domain.tld", "Peter"));
$swift->disconnect();
?>I've asked my webhost the limit of sending emails per second, they told me that the limit is 32 mails/sec inbound and 16 mails/second outbound. This shouldn't be the problem, but how come on my other webhost the same script is well very fast? Could be the reason that this webhost is running windows and IIS and my secondary webhost an linux distrubution with appache running?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: It takes long to sent the mail out
Thank you!Stitch wrote:Josh: I have tried the normal send and the batchSend function, it doesn't matter it takes the same time.
batchSend() is just a big foreach() around send(). The optimization happens at a much lower level than inside the batch send function (i.e. within the storage layer of the mime components).
In other words, batchSend() vs. send() is the same speed (roughly speaking). The only difference with batchSend() is that it tries it best to handle errors on your behalf.