SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: faster mail()

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    faster mail()

    Hi, I have a mail script, and It takes a while to finsih the entire list of emails... righ tnow it sends out 1 email for every user.. when we got over 900 users, its takes a while

    heres my code
    PHP Code:
    while ($row =  mysql_fetch_array($result))
                    {
                        
                        
    $to $row[email];
    $content="blah";
    $from="fdsafa";
                        
                                            
                        
    mail($to$subject$content"FROM:".$from)
                            or die (
    "error sending mail");
                        echo 
    "<center>Mail sent to $row[name]<br>";
                    } 
    Is there way to speed this up a little. Maybe I way to send it to all the users in one email..
    I havnt seen them for a few years, but isnt there such thing as a bcc? similar to cc, but u dont see who else the message was sent to (blind-carbon-copy)

    any help would be great

    thanx

  2. #2
    Idea Developer
    Join Date
    Sep 2000
    Location
    Bethlehem, PA
    Posts
    521
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use bcc, cant you?

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats kinda of what Im asking.. also, if it is possible, how can it be done?

  4. #4
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    BCC

    Hi,

    it's quite easy. I can't reach the PHP site at the moment to get the exact syntax, but BCC is part of the $headers of the mail parameters

    mail($recipient, $subject, $message, $headers);

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only caveat to using BCC is that the recepient's address does not appear in the To line. Some email clients will classify this as junk mail, so the recipient may never view it.

    Using BCC will probably work fine, but a few users may have trouble with it.
    David Baxter
    Freelance PHP/MySQL Developer
    Contact me for more information: [ Email ] [ICQ: 47136518]

  6. #6
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try using sockets to send the mail or sin sendmail directly. All sorts of ways but at the moment you could do:

    PHP Code:
    $content="blah";
    $from="fdsafa";

    while (
    $row =  mysql_fetch_array($result))
                    {
                        
                        
    $to $row[email];
                        
    mail($to$subject$content"FROM:".$from)
                            or die (
    "error sending mail");
                        echo 
    "<center>Mail sent to $row[name]<br>";
                    } 
    That just may speed it up slightly. Example for my script, I do a str_replace to insert emails, unsubscribe links and more but it causes serious bog downs doing it for everyone email for eveyone one so I did an reg exp to see before the email is sent whether the email, etc... is going to be added, if not then it saves a LOT or time.

    -Peter

  7. #7
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there a limit of ppl that can be in hte bcc: header

  8. #8
    SitePoint Enthusiast Fuseblown's Avatar
    Join Date
    Jul 2001
    Location
    State College, PA
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't use BCC and use CC or To: instead, then the other people on the list could hit 'reply all' and send messages to everyone that is on your list. I'm not sure what the limit on BCC is, but if you figure it out, you can always set it up to send it to two different groups or however many you need for your amount of recipients.

    Just a couple of thoughts..
    Fuseblown


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
  •