0

I'm trying to email to an array of subscribers to a weekly newsletter. Whenever I try though, I get an error "Bad parameters to function mail()". Heres the loop I'm using to mail:

$x = 0;
$y = 1;
while ($x <= $y)
{
    mail($names[$x], "Hey", "Whats up?");
    $x++;
}

Any help would be appreciated, thanks.

5
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by jamshid
0

Check the array. While function works fine to me. I have done it like this:

$names[] = 'name1@host.tld';
	$names[] = 'name2@host.tld';
	$names[] = 'name3@host.tld';
	
	$x = 0;
	$y = 2;
	while ($x <= $y)
	{
	    mail($names[$x], "hey", "whats up?");
	    $x++;
	}

Bye.

0

If you use foreach() you won't even need to bother with the indexing.

<?php
$list[] = "first";
$list[] = "second";
$list[] = "third";

foreach ($list as $entry){
  mail($entry, "Hey", "Whats up?");
}
?>
0

I populated the array with a loop, that read the names from a text file. I tried doing it manually, and it worked, but I cant do it that way for what I'm doing. @Ezzaral: What is foreach()? Would that help?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.