Page 1 of 1

email

Posted: Thu Oct 13, 2005 1:15 pm
by elecktricity
I have a comment adding thing on my site, which when you add it you have to add an email address, I was wondering if anybody knew a script I could use to send an email to all of them like a mass email thing? without repeating for each comment, any links would be helpful

Posted: Thu Oct 13, 2005 1:46 pm
by J_Iceman05
I'm sure this is not the most efficient way to do that, but it may be a way none the less...
Just so you know, I am writing this off the top of my head, so I'm sure there will be errors. I just hope this helps

if you have the e-mail address put into a database when they add a comment, and the address doing exist. then that will help a lot, but if not; you could write soemthing like

Code: Select all

$count = 0;
$max = $number_of_comments;
$total_address = 0;
while ($count < $max) {
  $address_exsists = FALSE;
  $address = $comment[$count]['address'];
  
  $new = 0;
  while ($new < $count) {
    if ($email[$new] == $address) {
      $address_exsists = TRUE;
    }
    $new++;
  }
  
  if ($address_exsists = FALSE) {
    $email[$count] = $address;
    $total_address ++;
  }
}
That should get you all your e-mail address one time

then for the email portion

Code: Select all

$message = 'This is the body.  say what ever you want';

$sent = 0;
while ($sent < $total_address) {
  mail($email[$sent], 'Thanks for commenting', $message);
}
I hope this helps you, or at least points you in the right direction