NameSilo

Grab column from table and Php Mail?

Spaceship Spaceship
Watch
Impact
1
This should be simple but I'm overthinking this.

I want to grab a column called Email in my table which looks like this:

|-Name---------Email---------Group|
|[email protected]|
|[email protected]|

I simply need to grab the Email column and place it into an array which goes into a To: field of a simple php mail function like

Code:
<?php

$Name = "Da Duder"; //senders name
$email = "[email protected]"; //senders e-mail adress
$to = "[email protected]";
$to .= "[email protected]";
 $mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>
So the script should constantly add a new To field for each column it goes through.

Ideas and code would be helpful.

Thanks :o
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Grr I typed a reply but something killed it.

Anyway, if you're trying to send a single email to multiple recipients at once, you need to separate them with commas:

$to .= ", $nextEmail";

will work, as long as $nextEmail is the variable that holds the current row's email address in it. You need to loop through the results of your mysql_query function and you might find it easiest to use mysql_fetch_array. Do you know how to do that?
 
0
•••
Thanks; I sort of know how to use mysql_fetch_array, although I don't know how to put it into a list separated by commas...
 
0
•••
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back