--- fremaje31 <[EMAIL PROTECTED]> wrote:

> First of all, thanks Billy for you help yesterday.  
> 
> My code will only send emails to the first email address of a group.  
> I'm not sure why it doesn't recognize the other email addresses in 
> the box.
> 
> Here's the link to the page -  
> http://mybusinesscircle.startlogic.com/emailextrator_plaxo.php - I am 
> referring to.  Put two email in the box like this 
> [EMAIL PROTECTED],[EMAIL PROTECTED] and notice that only the first 
> email listed will get the email.
> 
> Here is the code.
> 
> <?php 
> //print_r($_POST);
> $to ="";
> 
> //echo ($_POST['recipient_list']);
> 
> $recipients = str_replace("\"","",$_POST['recipient_list']);
> $temp = explode(",", $recipients);            
> 
>               /* Email Validation Check */
>               foreach($temp as $value) {
>                       if (preg_match("/<(.*)>/", $value, $a)) 
>                       {   // i.e. abc <[EMAIL PROTECTED]> - 
> Extracting email from it
>                               $mem_email = trim($a[1]);
>                       }
>                       else {
>                               $mem_email = trim($value);      
>                               // [EMAIL PROTECTED]
>                       }                               

Some email servers do not interpret addresses within angle brackets (<>) well. 
They should be separated by commas as in your example per the RFC on email.

The section of code (above) where you label it as Email Validation Check does
not do anything to check the format of the address nor does it know if the
address is good.

Since you are assigning a value to $mem_email each time (and overwriting it on
subsequent loops) I would expect that only the last address (rather than the
first) would get the message.  You might care to put the values into an email
array and then use a join() to put the addresses in a comma-separated list.

$email_list[] = trim($value); // or your other expression

// outside the loop

$mem_email = (is_array($email_list) ? join(",", $email_list) : $email_list;

The conditional operator makes sure that $email_list is an array since the
join() only works with arrays and will otherwise throw an error or warning.  Of
course, if $email_list is not an array and no value has been placed in it, no
email will be sent out.

My same comments from before apply to using the @ before the mail() function.

James

Reply via email to