![]() |
| ||
| Mail to a list of people I'm trying to mail a newsletter to a list of people, but I get an error every time it tries to mail. Anyone know what I'm doing wrong? <?php Heres the error I get: Warning: mail(): Bad parameters to mail() function, mail not sent. in (Directory) on line 19 |
| ||
| Re: Mail to a list of people I don't see any problems in my first glance, try to put a print_r($names); somewhere and see whether the array contains email adresses valid for PHP to swallow ( http://nl3.php.net/manual/en/function.mail.php ).BTW, $x = 1;, shouldn't that be $x = 0;? Or does the file your loading first have an empty line or something like it?You might to want to check your php.ini is fully configured for sending mail: http://nl3.php.net/manual/en/ref.mail.php . |
| ||
| Re: Mail to a list of people You can simplify your file handling by using file_get_contents() followed by an explode(), should the problem lie in invalid email address. http://nl3.php.net/manual/en/functio...t-contents.php http://nl3.php.net/explode |
| ||
| Re: Mail to a list of people There are no invalid e-mails, and I found that if I hard code it, it will work. However I can't hard code it for what I'm trying to do, so anyway I can fix it? |
| ||
| Re: Mail to a list of people As Anon said above, drop in a print_r or var_dump of $names to see what you have there. Also, foreach ($names as $to) { would make your loop a bit easier. |
| ||
| Re: Mail to a list of people Quote:
1.Always test if the file exists , first : if(!file_exists("to.txt")) 2.$names[$x] = fgets($sub);I assume you are familiar with C , but in php it's easier to do this: $names[]=fgets($sub);It will start from 0 and get on the next element at every loop. And later if you wanna know the number of elements in the array,you can use count($names); 3.With strings you can also use a very used shortcut, so instead of: $content = $content . fgets($file);you cand just as easily write : $content.=fgets($file);which does the same thing Anyway,back to our sheeps , the $names[] array is the problem. As the others said,try to print it out , see if you have the correct info. Oh,and btw,I hope you are running the script from a server that supports the mail() function( not the localhost) |
| ||
| Re: Mail to a list of people $x = 1; Change this to $x = 0; There is no records at $names[0] which is where the while loop is starting |
| All times are GMT -4. The time now is 11:40 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC