Jump to content

sending to multiple email addresses problem


jas4

Recommended Posts

Hi I'm collecting a string of email addresses from a mysql database(so the number of addresses varies), then allowing the user to enter an email subject and message, click on a button and send the email.

 

I use a for loop to add the email address to a string like ($postvars is an array that the email address is stored):

 

$string = null;                
  foreach ($postvars as $value)
  {
  $string .= $value."&&&@&&";
  }

 

and then I put the string in a hidden field in a form like:

 

<input type="hidden" value="<?php echo $string?>" name="string">

 

and then once the form is clicked i use explose to seperate the string like this:

 

$emailAddress = explode('&&&@&&', $string);
foreach ($emailAddress AS $memail){
//send to email here }

 

the problem is that I always get one extra blank entry after I have exploded therefore the loop tries to send an email to a blank address which of course is no good.

 

has anyone got any suggestions on how to fix / neaten this code up (lets face it, its pretty messy)

 

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.