The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 2 of 2

Thread: PHP mail with multiple addresses

  1. #1
    102
    posts
    Registered User

    PHP mail with multiple addresses

    I'm trying to send an email to everyone from a database list. I have attached the code. For some reason this code never sends the emails out. It only works if the $to variable is set to one person and one person only.

    Code:
    $to = "matthew.oconnor@comcast.net";
    but here is the code that doesn't work. Any hints?
    Code:
    <?php
    mysql_select_db($database_connPavlishDB, $connPavlishDB);
    $query_rsSpecials1 = "SELECT * FROM specials";
    $rsSpecials1 = mysql_query($query_rsSpecials1, $connPavlishDB) or die(mysql_error());
    $row_rsSpecials1 = mysql_fetch_assoc($rsSpecials1);
    $totalRows_rsSpecials1 = mysql_num_rows($rsSpecials1);
    
    mysql_select_db($database_connPavlishDB, $connPavlishDB);
    $query_rsEmails = "SELECT * FROM customers";
    $rsEmails = mysql_query($query_rsEmails, $connPavlishDB) or die(mysql_error());
    $row_rsEmails = mysql_fetch_assoc($rsEmails);
    $totalRows_rsEmails = mysql_num_rows($rsEmails);
    ?> 
    
    <?php $var1 = "Here are the current specials at Pavlish Beverage.\n\n"?>
    <?php do { ?>
    <?php 
    $var1 .= $row_rsSpecials1['name'];
    $var1 .= " ";
    $var1 .= $row_rsSpecials1['quantity']; 
    $var1 .= " for ";
    $var1 .= $row_rsSpecials1['price'];
    $var1 .= ".\n" 
    ?>
    <?php } while ($row_rsSpecials1 = mysql_fetch_assoc($rsSpecials1)); ?>
    <?php $var1 .= "\n\nHave A Good 1!\n\nPavlish Beverage\n(610)866-7722\nhttp://www.PavlishBev.com" ?>
    
    <?php do { ?>
    <?php 
    $var2 = $row_rsEmails['email']; 
    $var2 .= ",\n";
    ?>
    <?php } while ($row_rsEmails = mysql_fetch_assoc($rsEmails)); ?>
    
    <?php  
    $to = "$var2";
    $subject = "Pavlish Beverage Alert!";
    $message =  "$var1";
    
    mail($to,$subject,$message);
    ?>

  2. #2
    102
    posts
    Registered User
    i fixed it!

    Basically i wrote in one permanent address, then looped thru the others, than added another permanent one so that last ", " wasnt just hanging off the end there. I discovered you need a comma, then space to separate email addresses in PHP.

    now does anyone know if i can make these invisible to the individual users?

    Code:
    <?php 
    $var2 = "matthew.o'connor@lmco.com";
    $var2 .=", ";
    ?>
    <?php do { ?>
    <?php 
    $var2 .= $row_rsCustomers['email'];
    $var2 .= ", ";
    ?>
    <?php } while ($row_rsCustomers = mysql_fetch_assoc($rsCustomers)); ?>
    <?php 
    $var2 .= "matthew.oconnor@comcast.net";
    ?>
    
    <?php  
    $to = "$var2";
    $subject = "Pavlish Beverage Alert!";
    $message =  "$var1";
    $from = "Pavlish Beverage";
    $from_header = "From: $from";
    
    mail($to,$subject,$message,$from_header);
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012