View Full Version : PHP Mail not sending more than 1 email

05-14-2004, 02:44 PM
this is a php script. It works well but doesn't seem to send more than an email.... Can anyone help me out so that the script can be sent to more than one email using comma or whatever for seperation. thanx

if ($state == "")


$announce="Your message has been sent successfully...";
if ($ccText != "") $ccText="cc: $ccText <$ccText>\n";
if ($bccText != "") $bccText="Bcc: $bccText <$bccText>\n";
if ($mailformat == "Text") mail($toText, $subjectText, $msgText, "To: $toText <$toText>\n" . "From: $fromText <$fromText>\n" .$ccText.$bccText. "X-Mailer: PHP 4.x");
if ($mailformat == "Html") mail($toText, $subjectText, $msgText, "To: $toText <$toText>\n" . "From: $fromText <$fromText>\n" .$ccText.$bccText. "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");

<?php echo($announce)?>

05-15-2004, 02:46 AM
If nothing else, this script may spark an idea for you.

I didn't test it, as my inlaws might think I like them if I send them more than one email a week :)

// this script presumes the following:
// 1. the data is in a text file
// 2. each record has the format of first_name|last_name|email_address
// NOTE: with a little work you can adapt this to use a mysql database table for your data source

// put the entire csv file into an array

$all_lines = file('people.txt');

// count the number of lines in the file and store it in a variable

$how_many_lines = count($all_lines);

// take each line and
// 1. separate each line into its individual elements (aka fields aka pieces of information)
// using the EXPLODE () function.
// 2. grab the value(s) you are going to test and place them in a variable(s). Remember the
// count for the elements starts at 0 (zero). Also be careful that your variables don't
// contain extraneous parts (like extra spaces, newlines and tabs). Use the TRIM() function to
// clean up.
// 3. do your evaluation.

for ($i = 0; $i < $how_many_lines; $i++) {
$all_fields[$i] = explode(',', $all_lines[$i]);
$first_name = trim($all_fields[$i] [0]);
$last_name = trim($all_fields[$i] [1]);
$email_address = trim($all_fields[$i] [2]);
// send the email
$subject = "Your Registration!";
$message = "Dear $first_name $last_name,

Thank you for registering at our website, http://www.whatever..com!

Please print and save this information.
(this is the information supplied on the Registration Page)

Just type your message here
make it as long as you want

If you have any questions, or this registration is not
correct, please contact us.


The Joe Camel

This is an automated response, please do not reply!";

mail($email_address, $subject, $message,

"From: Webmaster<joecamel@whatever.com>\n

X-Mailer: PHP/" . phpversion());


05-17-2004, 08:28 AM
hope the script can send more than to 1 email....thanx