Re: [PHP] Re: Individual bulk e-mails - performance question



Well, I agree that sending it by an external process more specialized
in sending emails can be faster and more eficient, but it's harder to
control... sometimes you need to know in your php if email was really
sent and do something, and while I'm not saying it's impossible, I'm
sure it's a little more complicated...

Yet, if sending email don't need to be tracked, then external tool
world possible be better...

Anyway, don't ask me how to do that, I'm more confortable doing things in PHP :)

On Sun, Aug 31, 2008 at 2:31 AM, Manuel Lemos <mlemos@xxxxxxx> wrote:
Hello,

on 08/30/2008 02:40 PM Merlin said the following:

I am running a travel community where users want to get informed on
changes inside different groups they have subscribed to.

At the moment I am doing this with a for loop that generates an individual
e-mail sent to them via phpmailer. That works, however the submit of the
content upload form (that triggers the e-mail notification) now takes
several seconds, as more and more users subscribe.

I am thinking about placing the info on the individual e-mail inside a
ascii txt file that will be read by a cron job which will send the e-mail
instead. Something like every 5 minutes reading it line by line and then
after sending it removing the line.
e.g:
for:bla@xxxxxxx; body:individual
for:new@xxxxxxxxxxxxx; body:other email

Does this sound like a plan? Or do you believe that there are better ways
doing it? I could imagine that I would run into problems a few months from
now if for example the cron job will be triggered a second time, while the
first one has not finished.

Any ideas or suggestions? Thank you for any help.

While it is a good idea to off-load e-mail delivery to a script run from
cron, it seems odd that each mail takes several seconds to deliver.

I suspect that you sending messages in a less efficient way. Maybe you are
queueing messages using SMTP (which is the slowest way to queue messages) or
you are using sendmail on your system and it is configured by default to
attempt to deliver the messages immediately, making your PHP script hang
while the message is not accepted by the remote server.

There are much better ways to do it by just telling the mail system to queue
the messages without holding on the PHP script.

On the other hand, if the time it takes build your messages but the messages
have the same contents for all the receipients, you can also use some good
e-mail components with caching support.

In that case, I recommend that you use for instance this MIME message class
that provides message body caching support, so you can send messages to
different receipients and cache the building of message body parts and avoid
overhead when sending to a new receipient.

It also provides different means to send messages and solve the overhead of
message delivery by forcing the messages to queue by your local and be
delivered later whenever possible, so your PHP script is freed to send
messages to other recipients.


http://www.phpclasses.org/mimemessage


--

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
Thanks for your attention,

Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt
.



Relevant Pages

  • Re: How to send form data to email id by using PHP
    ... and how to run the php code, Please send the PHPCODE and Procee,I will ... But be warned, even veteran PHP programmers make mistakes with emailing, ... Like the abovementioned header-injection. ... for sending emails that have both text and HTML ...
    (comp.lang.php)
  • [SLE] Fatal error: Call to undefined function: mail()
    ... I'm having a problem with php at the moment that stops me from sending emails. ... As far as I can find out it would apear that when php was installed it could not find the sendmail program! ... Any ideas how I recompile php? ... as I used yast2 to install it. ...
    (SuSE)
  • Re: Attempt to de-mystify AJAX
    ... created and populated by the PHP script. ... string is initialized in line 1 to the opening select tag. ...
    (comp.databases.pick)
  • Re: File permissions for a wiki-like site
    ... the content using PHP scripts. ... content to be writable by my PHP script. ... The only one doing the writing will be the Apache user itself. ... The web user is used for things like ...
    (comp.lang.php)
  • Re: File permissions for a wiki-like site
    ... the content using PHP scripts. ... content to be writable by my PHP script. ... The only one doing the writing will be the Apache user itself. ... The web user is used for things like ...
    (comp.lang.php)