Re: need to send email to 1000 addresses (currently in MS Excel)- what's the best way to do that, create a mail forma and paste ALL 1000 addresses in the TO field?

From: Eric Kincl (Eric_at_Kincl.net_NO_SPAM_)
Date: 11/20/03


Date: Thu, 20 Nov 2003 00:29:13 +0000

NotGiven wrote:

> Perhaps I did not post it correctly or explain myself well. Most people I
> email appreciate putting the question in the subject line so they know
> what
> I am asking for without reading the entire email. Live & learn.
>
> I'd like to quickly develop a way send email to about 1000 people using
> php. I thought about exporting the excel file to text then pasting &
> coding each line as an array then looping through the array with mail().
>
> Do you know of a quicker way?
>
>
>
>
> "Eric Kincl" <Eric@Kincl.net_NO_SPAM_> wrote in message
> news:3fbbf382@news.gvsu.edu...
>> Next time, try writing your message in the body, not in the subject line.
>> Also, as a common courtesy, please include your name, or at least your
>> handle, and email address. (It is smart to mask your email, such as "me
> AT
>> domain DOT com" so that webcrawlers can't add it to spam lists.) Lastly,
>> don't post a question that doesn't have anything to remotely do with PHP,
>> to the PHP group. Posting to the proper group will not only get you a
>> response faster, it will help keep the group on topic.
>>
>> Thanks,
>>
>>
>> -Eric Kincl

Hey,
I'm actually doing something to that extent right now. What it does is take
a string (from a textarea... it simply strips the \n tags so php sees it as
one huge string) and then it splits that string into an array of arrays.
(the way it works it could easily stand for rows and columns of an excel
***...) Here is the code I have so far. Keep in mind that I am actually
working on it this exact moment, and it may not be perfect, it seems to
work so far though for my means.

function string2namesArray(){
        $Nsep = ";"; // Name separator
        $FLsep = ","; // Last/First name Separator

        if(isset($_REQUEST['names'])){
                $names = $_REQUEST['names'];

                // Compound the string - get rid of newlines, spaces, etc...
                $names = str_replace(" ", "", $names);
                $names = str_replace("\n", "", $names);
                $names = str_replace("\r", "", $names);
                // I forget which way it is on windows...
                $names = str_replace("\n\r", "", $names);
                $names = str_replace("\r\n", "", $names);
                $names = str_replace("\t", "", $names);

                // Strip last ";", if present
                // the last ";" apparently causes an extra array index that is unnessasary
                // BETA CODE
                if(strrpos($names, $Nsep) == (strlen($names) - 1)){
                        $names = substr($names, 0, (strlen($names) - 1));
                }
                // END BETA CODE

                $namesArray = explode($Nsep, $names); // Split on ";" and make array
                $i = 0;
                while($namesArray[$i]){
                        // split on "," and make an array inside of index [i]
                        // Since there can only be first/last name, make max array length 2
                        $namesArray[$i] = explode($FLsep, $namesArray[$i], 2);
                        $i++;
                }
        return $namesArray;
        }
}

To give you an idea of what this program does, there is a textarea in which
a person can enter a set of names in the following syntax:
last, first;
It then takes this list, and puts it into an array of arrays as follows:
String = "last, first; last2, first2;"
Array
(
    [0] => Array
        (
            [0] => last
            [1] => first
        )

    [1] => Array
        (
            [0] => last2
            [1] => first2
        )

)
Newlines etc don't bother it. If you could modify this slightly (I think
you just have to get rid of the "2" in this line:
$namesArray[$i] = explode($FLsep, $namesArray[$i], 2);
And that should do it... Also change the $FLsep and $Nsep to be whatever
the row/column seperators are in the text file.

Lastly, don't send multiple e-mails. This takes up a ton of bandwidth on
your end. CC it, or even better, BCC it so that those being emailed can't
see the other peoples email addresses. I don't know how to BCC in PHP, or
even email in PHP. Check php.net for that info.

Good Luck,

-Eric Kincl