Writing my own mass-email script in PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeffrey Silverman

    Writing my own mass-email script in PHP

    Hi, all. Sorry, first off, for the kidna weird selection of crossposted
    groups, but this question touches on aspects of discussion in each of the
    groups.

    So I have a group of around 500 email addresses to which I would like to
    send a mass email occasionally. The group will never be much larger than
    500 email addresses and will occasionally be about half that size.

    I have written a simple HTML interface and PHP backend to process the
    mail. HTML form wiht "subject" and "message body" fields. PHP then gets
    all this, gets a list of addresses from a database, and sends the email
    out.

    What is a good way to proceed with this?

    I would like to Bcc: the names on the list so that the "To:" is "Mail
    List<maillist@m ydomain.edu>" (which is a dummy email address).

    I tried using the PHP mail() function and it *seemed* to work, almost.
    That is to say, I had added all the names to a long list of Bcc: headers,
    and put the extra Bcc: headers in the extra headers argument to the PHP
    mail() function. This seemed to work, in that it seemed like everyone got
    the email; however, the mail() function came back with a failure error.

    I thought about it a bit and researched a little and found that maybe a
    really long Bcc: list is not the best idea, for spam reasons (my
    message is more likely to be marked as spam) and for other similar
    reasons. So I was considering looping through the 500 email addresses and
    doing a separate mail() for each, but putting each email address in the
    To: field. This sounds like a lot of overhead, though, and I'm afraid of
    this thing timing out or crapping out or Something Bad(TM) happening.

    I am currently using Sendmail, Linux (Red Hat 9), Apache 1.3.x, and PHP
    4.3.8.

    I am not crazy about the idea of installing EZMLM only because I would
    need to install Qmail and, although that may be a good idea in the long
    run, it looks like a bitch (if the length of this page --
    http://www.lifewithqmail.org/lwq.html -- is any indication!) I am not
    really very experienced with MTA administration!

    So, any suggestions? Any comments? Anything?

    Thanks!!

    --
    Jeffrey D. Silverman | jeffreyPANTS@jh u.edu
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email

  • AJ

    #2
    Re: Writing my own mass-email script in PHP


    "Jeffrey Silverman" <jeffrey@pantsj hu.edu> wrote in message
    news:pan.2004.0 9.27.16.22.47.5 89264@pantsjhu. edu...[color=blue]
    > Hi, all. Sorry, first off, for the kidna weird selection of crossposted
    > groups, but this question touches on aspects of discussion in each of the
    > groups.
    >
    > So I have a group of around 500 email addresses to which I would like to
    > send a mass email occasionally. The group will never be much larger than
    > 500 email addresses and will occasionally be about half that size.
    >
    > I have written a simple HTML interface and PHP backend to process the
    > mail. HTML form wiht "subject" and "message body" fields. PHP then gets
    > all this, gets a list of addresses from a database, and sends the email
    > out.
    >
    > What is a good way to proceed with this?[/color]

    I've got something like this that sends all the mails out individually
    according to recipients specified in a MySQL table. I've sent to just over
    1500 people and it worked fine.

    It also has an online thing so that you can edit the actual message that
    goes out.

    If you want, e-mail me offline and I'll zip up the relevant files and send
    them to you. I can't promise that the code will be very elegant but you're
    welcome to it.

    Andy


    Comment

    • J.O. Aho

      #3
      Re: Writing my own mass-email script in PHP

      Jeffrey Silverman wrote:
      [color=blue]
      > I tried using the PHP mail() function and it *seemed* to work, almost.
      > That is to say, I had added all the names to a long list of Bcc: headers,
      > and put the extra Bcc: headers in the extra headers argument to the PHP
      > mail() function. This seemed to work, in that it seemed like everyone got
      > the email; however, the mail() function came back with a failure error.[/color]

      You could select a smaller number of adresses to bcc: and then loop all your
      emails in groups, this would lessen the send load on your mailserver, and at
      the same time allow you to send the same message to all the users in your list.


      //Aho

      Comment

      • Manuel Lemos

        #4
        Re: Writing my own mass-email script in PHP

        Hello,

        On 09/27/2004 01:22 PM, Jeffrey Silverman wrote:[color=blue]
        > I tried using the PHP mail() function and it *seemed* to work, almost.
        > That is to say, I had added all the names to a long list of Bcc: headers,
        > and put the extra Bcc: headers in the extra headers argument to the PHP
        > mail() function. This seemed to work, in that it seemed like everyone got
        > the email; however, the mail() function came back with a failure error.
        >
        > I thought about it a bit and researched a little and found that maybe a
        > really long Bcc: list is not the best idea, for spam reasons (my
        > message is more likely to be marked as spam) and for other similar
        > reasons. So I was considering looping through the 500 email addresses and
        > doing a separate mail() for each, but putting each email address in the
        > To: field. This sounds like a lot of overhead, though, and I'm afraid of
        > this thing timing out or crapping out or Something Bad(TM) happening.
        >
        > I am currently using Sendmail, Linux (Red Hat 9), Apache 1.3.x, and PHP
        > 4.3.8.[/color]

        You are right. Putting all recipients in Bcc: is not a good idea because
        like you noted, some mailbox providers like Hotmail will tag the
        messages as junk when the recipient address does not come in a visible
        header (To: or Ccc:). Some ISP may also limit the number of recipients
        per message that is queued.

        Since you use sendmail and your messages are not that urgent, my
        suggestion is to configure it to queue all the messages and deliver them
        later when the queue is processed next time. This way sendmail will not
        hold your PHP script waiting for each delivery.

        If you are not aware how to do that, you may want to try this class for
        composing and sending e-mail messages that comes with a subclass
        specialized in deliveryng via sendmail that provides an option that lets
        you tell to defer the delivery of your messages.

        If you are not personalizing the messages (which I strongly advise for
        efficiency reasons) you may also want to tell the class to cache your
        message bodies so it does not waste time rebuilding the message body for
        each recipient. You can still personalize the message headers like the
        To: header as you need.





        --

        Regards,
        Manuel Lemos

        PHP Classes - Free ready to use OOP components written in PHP
        Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


        PHP Reviews - Reviews of PHP books and other products


        Metastorage - Data object relational mapping layer generator

        Comment

        • Jeffrey Silverman

          #5
          Re: Writing my own mass-email script in PHP

          On Mon, 27 Sep 2004 14:35:23 -0300, Manuel Lemos wrote:
          [color=blue]
          > http://www.phpclasses.org/mimemessage[/color]

          Thanks! This looks promising...

          --
          Jeffrey D. Silverman | jeffreyPANTS@jh u.edu
          Website | http://www.newtnotes.com

          Drop "PANTS" to reply by email

          Comment

          • Dave Kelly

            #6
            Re: Writing my own mass-email script in PHP

            Jeffrey Silverman wrote:
            [color=blue]
            > So I have a group of around 500 email addresses to which I would like to
            > send a mass email occasionally. The group will never be much larger than
            > 500 email addresses and will occasionally be about half that size.[/color]
            This was the subject of a question I ask about a membership list about a
            year or two ago.

            If you will do a google groups search for 'membership list' without the
            quotes as a subject, you should find 6 or 8 messages that answer your
            question.

            Comment

            • DrTebi

              #7
              Re: Writing my own mass-email script in PHP

              On Mon, 27 Sep 2004 12:22:48 -0400, Jeffrey Silverman wrote:
              [color=blue]
              > Hi, all. Sorry, first off, for the kidna weird selection of crossposted
              > groups, but this question touches on aspects of discussion in each of the
              > groups.
              >
              > So I have a group of around 500 email addresses to which I would like to
              > send a mass email occasionally. The group will never be much larger than
              > 500 email addresses and will occasionally be about half that size.
              >[/color]
              [color=blue][color=green]
              >> snip <<<[/color][/color]

              Hi,
              I have worked on something like that, I ended up installing bulk_mailer:
              ftp://cs.utk.edu/pub/moore/bulk_mailer/
              This is a C program which will do quite smart mass-mailing, I have used it
              once or twice for the about 5000 subscribers of my newsletter, it worked
              without problems.

              Since I do everything in PHP as well, and needed to write a web-based
              frontend for this newsletter, I simply used the system function from PHP
              to use bulk_mailer. It looked something like that:
              system('/bin/cat '.PATH_MESSAGE. ' | '.PATH_BULK_MAI LER.' '.$from.'
              '.PATH_RECIPIEN TS.' > '.$path_log.' 2>/dev/null');

              Before this, I first wrote the newsletter to a file (PATH_MESSAGE), and
              the recipients to a file (PATH_RECIPIENT S).
              As you can see in the command above, I pipe the contents of the message
              (PATH_MESSAGE) into bulk_mailer (PATH_BULK_MAIL ER), then set the sender
              ($from) and recipient list (PATH_RECIPIENT S) arguments for bulkmailer.
              Finally, I redirected the output into a log ($path_log) and ditched any
              error output.

              Of course you will have to write some error checks and elsewhat before
              using this, but it could give you a hint.

              The good news is, bulk_mailer works with sendmail, the bad news is,
              bulk_mailer does not seem to work with qmail :(

              DrTebi


              Comment

              Working...