Results 1 to 2 of 2

Thread: How to send batch email in php?

  1. #1
    Join Date
    Jun 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to send batch email in php?

    Hi there,

    am currently writing a mass mail web application in php. The thing is that the software should be able to send e-mail in batches and pause interval between.

    I wrote this little script to send in batch:


    PHP Code:
    if($totalemails <= 5000) {          
        
    $batch      =   400;
        
    $interval           =   60;
    } elseif(
    $totalemails <= 15000) {      
        
    $batch      =   500;
        
    $interval           =   90;
    } elseif(
    $totalemails <= 30000) {      
        
    $batch      =   300;
        
    $interval           =   120;
    } elseif(
    $totalemails <= 50000) {      
        
    $batch      =   200;
        
    $interval           =   120;
    } else {
        
    $batch      =   100;
        
    $interval   =   180;


    But the above script is the wrong way because if the user has 400 emails. The system will send all the 400 recipient at one time hence no pause interval.

    Can you please help me the find a solution to this? The system should calculate how many batch either $totalemails = 400 or $totalemails = 40000 for example.

    The interval can be 60 seconds in every cases.

    Waiting for you help.
    Thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That's just assigning values to variables. You could use a switch statement instead if you'd like, but it's somewhat irrelevant. The code that will actually determine the action must be in the sending loop.

    You can use the sleep() function to pause for a certain number of seconds.


    But be careful sending "mass emails" with PHP. There are probably limits in place by your server, or potentially the ISP, and you may be marked as spam. There also may be legal limits depending on the specifics of your situation.


    Note that there are some available software products (some free even) for newsletters and so forth, including lots of messages. This might be easier if you're just looking for a solution rather than intending to build it using your own code specifically.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •