Hello,

On 08/16/2002 05:37 PM, Daren Cotter wrote:
> First, a recap of my problem:
> 
> I need to send personalized emails to my member list
> on a daily basis. I use PHP to query the MySQL
> database, and loop through the results using the
> mail() function. Problem: very slow, browser/php times
> out, etc.
> 
> Solution:
> 
> First, I configure sendmail to use "queueonly" as the
> DeliveryMethod (see sendmail.cf) instead of
> "background". Then, when my PHP script runs, mailings
> simply get queued instead of actually delivered. This
> is a x10 speed increase. My script queues
> approximately 1,000 mailings per minute (a x10 speed
> increase). Then, I modified the
> /etc/rc.d/init.d/sendmail script to process the queue
> every 5 minutes, instead of the default one hour. This
> insures that the mailings actually get sent soon after
> they're queued, and you won't have to wait for
> important emails to come through.

As I mentioned before this solution is set for disaster as you grow into 
larger number of recipients. The problem is that queuing separate 
messages for each recipient will fill up your disk. But that is not all. 
The eventual message bounces that you will get will only aggravate your 
problem. If you can live without personalization, don't think twice, 
forget it. If you have doubts, think again.



> The problem with the above solution used to be this:
> certain emails generated from my site (welcome emails,
> password lookup emails, etc) need to be sent
> IMMEDIATELY, and cannot wait in the queue for 5
> minutes. The solution for this: not using the built-in
> mail() command in PHP. I created my own mail script
> (by modifying something someone else already did)
> which opens a socket directly with the mail server.
> Code is below.
> 
> // Sends the email directly to the mail server using
> SMTP. This is done
> // so sendmail can be setup using the queue method on
> the server, and
> // confirmation emails, etc, can be sent immediately
> to the member.
> function smtp_mail($to, $from_name, $from_email,
> $reply_to_email, $subject, $body) {
>       $smtp = fsockopen("your_mail_server_here", 25);

I am not sure that sending to the local mailer queue via SMTP would be 
any better than using sendmail itself to put the message there. Anyway, 
I am afraid that the message will still wait for sendmail to process it


>       if ($smtp == 0)
>               return 0;
>       fputs($smtp,"helo
> machines_host_and_domain_name_here\r\n");
>               $line = fgets($smtp, 1024);
>       fputs($smtp,"mail from: $from_email\r\n");
>               $line = fgets($smtp, 1024);
>       fputs($smtp,"rcpt to: $to\r\n");
>               $line = fgets($smtp, 1024);
>       fputs($smtp,"data\r\n");
>               $line = fgets($smtp, 1024);
>       fputs($smtp,"From: $from_name <$from_email>\r\n");
>       fputs($smtp,"Reply-To: $reply_to_email\r\n");
>       fputs($smtp,"To: $to\r\n");
>       fputs($smtp,"Subject: $subject\r\n");
>       fputs($smtp,"\r\n");
>       fputs($smtp,"$body\r\n");
>       fputs($smtp,".\r\n");
>               $line = fgets($smtp, 1024);
>       fputs($smtp, "QUIT\r\n");
>       fclose($smtp);
>       return 1;
> }

I am afraid this code needs a lot of work or else it will choke on some 
servers due to multi-line responses, maybe not on the actual sendmail 
version and configuration you are using, but definetely on some SMTP 
servers.


-- 

Regards,
Manuel Lemos


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

Reply via email to