PDA

View Full Version : Resolved mail functional



bluewalrus
12-30-2008, 01:39 AM
Would the mail() work with multiple contacts, separated by a comma and a space, inside a variable, that's in the string to part?

ie...
$names = john@yahoo.com, john@gmail.com, john@whatever.com;
mail($names,something,something);

Nile
12-30-2008, 02:21 AM
Only if you put it in the headers:

$headers .= 'To: john@yahoo.com, john@gmail.com, john@whatever.com' . "\r\n";

Here: http://us3.php.net/manual/en/function.mail.php Scroll down to example #4.

bluewalrus
12-30-2008, 02:58 AM
okay this gonna be a jump ahead from my last post. I think this will all work though. I'm going to have a form that takes an entered user address and submits it to a text file with a comma and a space (after entering this description will the space stay or should i put in an  ?) then adds a new line so the text file will be not be chaotic to look at regular ( it may need to be chaotic not sure yet this is all a big test kinda). Another page where a newsletter or something could be sent out to all the addresses would then open the text file and add all the contents with the , and space to the, 'to' line and then add the message and subject to the email. I think it makes about 75% sense at least...

Form for submit email address

<?php
$name = $_POST['email'];
$file = "addresses.txt";
$handle = fopen($file, "r+");
$data = $name . ', ' . "\n";
fwrite($handle, $data);
fclose($handle);
?>
submit message to emails

<?php
$message = $_POST['message'];
$myfile = "addresses.txt";
$fh = fopen($myfile, 'r');
$thedata = fread($fh, 20000000);
fclose($fh);
$to = $thedata;
$subject = 'Subject test';
mail($to, $subject, $message);
echo 'Mail Sent';
?>

Nile
12-30-2008, 03:04 AM
Give it a try. Make sure to put it in the HEADERS though. And not the $to variable.

bluewalrus
12-30-2008, 03:14 AM
The headers weren't to make it an html email? It looked liked they used the to function and the headers there but I didn't want to use the headers because I wasn't going to send HTML emails. I don't actually have anything to test this with yet its just an idea.

Nile
12-30-2008, 03:16 AM
The header "To" is to send the email to multiple emails from what I know. Try both - I guess you should try your idea first, then if it doesn't work try mine. xD

bluewalrus
12-30-2008, 06:26 AM
Okay I'll give them both a try in a bit. Have you had a chance to look at the adding permission thread since I updated it last? That ones really annoying me now because it's on a live page and I have to keep logging into the ftp to change it to 777. Well anyways thanks for your replies to both of these.

bluewalrus
12-30-2008, 09:49 PM
I got it all working now.