PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Sep 23, 2019 3:20 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 53 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: Sat Jun 17, 2006 3:29 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Ok guys, for those with the questions about sending mail to thousandsof recipients and don't want to use cron... here you go:

The anti-flood plugin two posts above this one has been updated. The second constructor parameter is an optional pause in seconds between re-connection.

Lets say you want to send say 10,000 emails in batches of 100 at a time with a 10 second pause between each 100 to give the poor SMTP server a rest.

A combination of set_time_slimit() and ignore_user_abort() with the anti-flood plugin makes this possible.

You'd do something like this and then open it in your browser. As soon as the script starts to run just kill your browser window and the mails will be sent in the background with a 10 second pause between each 100. This will take (obviously) a minimum of 990 seconds + the network overhead for the data to be sent but you don't need to sit and wait. I tested it by sending 1000 emails to my won address with a disconnect after each 10 and a 2 second pause. It worked well even when I closed the browser.

Syntax: [ Download ] [ Hide ]
set_time_limit(0);

ignore_user_abort(); //Vital maybe



$swift = new Swift($connection);



//100 mails per connection, 10 second pause between connections

$swift->loadPlugin(new Swift_Anti_Flood_Plugin(100, 10));



$recipients = array(); //Fill this with the 10,000 recipients you want



$swift->send($recipients, $your_address, $subject, $body);



$swift->close();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 2:43 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 3:37 pm 
Offline
Tutorials Group

Joined: Sun Jan 04, 2004 11:30 pm
Posts: 2692


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 4:43 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 4:04 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
The following data was obtained using Xdebug on PHP4 (I can't get Xdebug working on PHP5!) for PHPMailer 1.73 and Swift 1.3.0.

OK all tests were run 10 ten times each, the figures shown are the averages but I should point out that Xdebug appears to be pretty close to a set figure since most often, anything beyond the second run returns *exactly* the same memory amount to the byte.

Sending a (unique) plain text mail over SMTP N times without stopping for a rest

Image

Indicates a consistent 44% memory saving at 1, 10, 30, and 100 emails.

------------------------------------------------

Sending an attachment with a size of N Kilobytes (generated using linux dd command on /dev/zero)

Image

This seems to indicate that Swift won't go beyond a 20% saving on memory (it hits a tangent) in comparison to PHPMailer but at small attachment sizes it can be as high as 42%. A significant saving all the same.

------------------------------------------------

Speed tests. I don't trust these too much with SMTP since network traffic varies but here it is in any case - confusing the hell out of me. Most of the time used should be SMTP traffic but I have no clue what goes on in PHPMailer :? I used SMTPKeepAlive too but still a big gap.

Image

You can read the overall comparison here: http://www.swiftmailer.org/phpmailer/

EDIT | Interestingly I just received an email from a developer who's done some speed tests of his own with an older version. His results are here: http://www.swiftmailer.org/contrib/phpm ... mailer.doc

They seem to correlate with what I'm seeing too.... very odd indeed.
(I'll be adding that (minor) fix that he gave for the bounce detection too).


Last edited by Chris Corbyn on Sun Jun 25, 2006 8:31 am, edited 6 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 9:52 am 
Offline
Forum Contributor

Joined: Wed Jan 12, 2005 6:24 pm
Posts: 173
10,000 email through a PHP script, not very good idea. ALL MTA or SMTP servers have better ways to deal with this, (envelopes). It just seems like hacking to me. This is a nice class, but for mass mailing, I don't think so! It would be better to send (1) message then envelope the RCPT To, sending that one message to all 10,000 recipients! By using a envelope, you save the outbound server and the receiving server loads a bandwidth because domains are grouped in the sending of the message! Say your 10,000 user mailing list has 1,150 google recipients, then SMTP/MTA will send one message to the google SMTP/MTA with the envelope and then the google SMTP/MTA will distribute the message to all recipients using the envelope!

pif!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 12:42 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 4:17 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 2:40 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
For those people who are relaying mail via Gmail SMTP servers and currently putting up with the re-written From: header (the reply-to still works) have a read of this:

http://www.mobileread.com/forums/showth ... eadid=4857


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 3:14 pm 
Offline
Tutorials Group

Joined: Sun Jan 04, 2004 11:30 pm
Posts: 2692
I meant to mention, as , I'll be looking at switching BNT to use Swift instead of Phpmailer in the near-term future. I'll be in touch when I run into problems. (Notice, not IF, when). :)

[[EDIT: I meant, sarcastically, that my ability to follow even simple directions is non-ideal. Not that there was anything wrong with Swift. :P ]]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 3:42 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 6:47 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
Awesome :) That's what I was hoping would happen :P

http://search.msn.co.uk/results.aspx?q= ... &FORM=QBHP

(Google still hasn't indexed it yet).


Top
 Profile  
 
 Post subject: utf-8 support?
PostPosted: Sun Jul 23, 2006 7:52 pm 
Offline
Forum Commoner

Joined: Mon May 22, 2006 3:54 pm
Posts: 46
Location: USA
Does this have utf-8 support? I'm getting my software to work in unicode so that it will work in 99% of the world's languages.

I'm not sure if you'd want to build-in utf-8 support, or if there is something that programmers should be doing before they get the email text into your script?

I've read something about needing to convert the email text to base64... I guess I'd want to be able to have the email text, subject header, and to: header in unicode.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 24, 2006 9:28 am 
Offline
DevNet Resident
User avatar

Joined: Mon Aug 22, 2005 12:11 pm
Posts: 1912
Location: Leeds/Manchester, England


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 24, 2006 9:38 am 
Offline
Site Admin
User avatar

Joined: Tue Dec 23, 2003 3:10 am
Posts: 11470
Location: Toronto


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 53 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] 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:  
cron
Powered by phpBB® Forum Software © phpBB Group