email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

email

Post 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
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

Post 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
Post Reply