Page 1 of 1

Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 6:25 pm
by alex.barylski
Quick question. I currently have send() called inside a tight loop - infact just swift::send() is called.

If all I need to change on a per emial basis is the To: address is it sufficient (and apparently faster?) to just call send() with the new address - this is what I would prefer? Will this in any way cause CC or BCc issues?

Should I reset the object after each send somehow?

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 6:28 pm
by Chris Corbyn
The only reason not to do that is if you want the try/catch logic which batchSend() does for you. batchSend() catches errors and retries addresses a second time before giving up... it won't completely halt on a error like send() alone will though ;)

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 6:43 pm
by alex.barylski
Chris Corbyn wrote:The only reason not to do that is if you want the try/catch logic which batchSend() does for you. batchSend() catches errors and retries addresses a second time before giving up... it won't completely halt on a error like send() alone will though ;)
Wow fast response. :)

So keeping send() inside a tight loop is a good practice. I was worried that maybe I would loose the ability to determine bounces or failures at least without keeping track of send() return values, but I see that getFailedRecipients will also tell me that.

I am worried about one thing. If Swift tracks failures, and there happens to be 10,000 failures...thats a lot of memory in PHP. It would perhaps be best to disable that functionality and log failures to a database on each send. I need the data persisted anyways and this way I avoid Swift accumulating to much memory??? Is this possible?

If when I call getFailedRecipients() does it clear the buffer? Perhaps I could call it every 50 emails sent so as not to constantly write to the DB and prevent too much overhead in terms of Swift memory use.

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 6:57 pm
by Chris Corbyn
Currently it will consume memory yes. It's something I was thinking about whilst re-thinking all the logging from version 3. I agree there needs to be a way to turn off tracking.

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 7:11 pm
by alex.barylski
A solution which would suit my system would be like:

You pass a boolean:

Code: Select all

getFailedRecipients(true);
This way I can retreive the contents of the buffer and if TRUE is passed the buffer is unset(). Any future errors just re-fill the array.

If you don't feel this is appropriate, should this not be a simple matter of adding some condiutional logic to the accessor and unset and reset the member variable??? Can you think of any ramifications of doing this?

p.s-The reason I ask is I will likely add that functionality to my own as I have no idea how many bounces may occur in the lifetime of sending newsletters.

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 7:17 pm
by alex.barylski
Hmmm...I'm trying to enable logging and I'm getting a an error copying this code:

Code: Select all

$swift =& new Swift(new Swift_Connection_SMTP("host.tld"));
$swift->log->enable();
Apparently enabled() is being called on a non-object? :?

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 7:20 pm
by Chris Corbyn
Read the docs... the API changed.

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 8:12 pm
by alex.barylski
I think I can actually more effectively log errors - at least in terms of memory. Instead of keeping an array of bounced emails I can just log the PKID of each email as an array of integers. :D

Another question though, if you don't mind. :)

What would cause a send() failure? I have tried in vein to make one email fail...and so far, the only thing thats bounced is a faulty email address (faulty-test-email instead of xxx@yyy.xyz). This resulted in failure but will *never* happen in my application as emails are verified to at least meet RFC compliance. Should I still bother checking for error codes? It seems even emails for domains I own but are inactive are still receiving emails.

I have included:

Code: Select all

$message->setReturnPath(mypersonal@email.ca');
In hopes I would receive bounce messages...but nothing yet.

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 9:24 pm
by Chris Corbyn
The typical failure is just when the server has been bombarded way too much and it doesn't respond... so Swift pauses for a couple of seconds, then retries.

What causes a failure is very SMTP-server specific. Some servers will do a MX or reverse DNS lookup for example. Some will even scan the email for spam or viruses. It sounds like your server merely checks if the recipient address has valid syntax.

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 10:28 pm
by alex.barylski
Chris Corbyn wrote:The typical failure is just when the server has been bombarded way too much and it doesn't respond... so Swift pauses for a couple of seconds, then retries.

What causes a failure is very SMTP-server specific. Some servers will do a MX or reverse DNS lookup for example. Some will even scan the email for spam or viruses. It sounds like your server merely checks if the recipient address has valid syntax.
Hmm...ok. Thanks for the heads up. :)

Re: Bulk mail batchSend or send

Posted: Mon Jan 28, 2008 11:49 pm
by alex.barylski
Just to add to this topic...

I just checked my Google email account, which I am using as SMTP test server as well. Despite having setReturnPath() to my personal email (so I could easily checked bounced messages) they all seem to be handled by the SMTP account itself. I suppose there is no way around this. I should probably assume then, that bounced messages will be first sent onto my SMTP server responsible for sending the email and then possibly forwarded onto the address set with Swift - if the SMTP server decides to do so...

Re: Bulk mail batchSend or send

Posted: Tue Jan 29, 2008 12:01 am
by Chris Corbyn
Hockey wrote:Just to add to this topic...

I just checked my Google email account, which I am using as SMTP test server as well. Despite having setReturnPath() to my personal email (so I could easily checked bounced messages) they all seem to be handled by the SMTP account itself. I suppose there is no way around this. I should probably assume then, that bounced messages will be first sent onto my SMTP server responsible for sending the email and then possibly forwarded onto the address set with Swift - if the SMTP server decides to do so...
That's just a gmail specific thing ;) Gmail rewrites message headers in its attempts to combat spamming (i.e. it doesn't want to risk allowing you to be anonymous).