Jump to content


Multiple addresses for only one Display name, Can be done?

  • Please log in to reply
1 reply to this topic

#1 Jegs

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 August 2006 - 01:47 PM

Hi guys

I'm new here! so sorry if this is off topic. I search teh forum if this thread was previously treated, but I didn't find anything.

The question is very simple. I'm sending mails throught php with the mail function, and using a plain text file to store the addresses that users have suscribed.

The text file has a simple format just like:

User1 <user1@domain.com>, User2 <user2@domain.com>

The php, reads the text file and associates it whole content to a variable called $to used to send the mail after. The previous formats works ok, but:

If for example a user wants to register two addresses how should I format it in the text file. I have tried this:

User3 <user3_address1@domain.com, user3_address2@domain.com>

but It doesn't work. Anyone could help please :D

Best regards

#2 kenrbnsn

  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 13 August 2006 - 02:09 PM

How you format it is really all up to you. It depends on how you're going to parse the file to get the information out.

You might want to look into the parse_ini_file() function (http://www.php.net/parse_ini_file), which will take a file in a particular format and return the information in an array.

In your case, if you change the format of your file to:
email[] = user1@example.com

email[] = user2@example.com

email[] = user3a@example.com
email[] = user3b@example.com

The results of using code something like this:
 $user_email = parse_ini_file('user_email.txt',true);
 echo '<pre>' . print_r($user_email,true) . '</pre>';
Is an array containing:
    [user1] => Array
            [email] => Array
                    [0] => user1@example.com


    [user2] => Array
            [email] => Array
                    [0] => user2@example.com


    [user3] => Array
            [email] => Array
                    [0] => user3a@example.com
                    [1] => user3b@example.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users