tags:

views:

122

answers:

3

i have a textarea... i want to send emails to all of the email addresses in textarea seperated with comma....i.e

[email protected], [email protected], [email protected]

also detect if user has type a single email address

A: 

If you're using PHP's mail function, it will accept comma-delimited addresses. Or, you could use the explode function to get the addresses, so

explode(',',$_REQUEST['addresses']) would provide you an array of addresses, from which you could loop through.

jnunn
+2  A: 

Use PHP explode and Send email.

Shoban
A: 

if your textarea input string is $s, then you could

$a = explode(',', preg_replace('/[,;\s]+/', ',', $s));

to get the addresses in an array. this is tolerant of a variety of delimiters between addresses.

then use your favorite regex for validating email addresses on each element of $a to select those that appear acceptable.

and then you can send each one an email or put them all as to: addresses on the one email. i use pear::mail.

however, the more addresses on one email, the more likely it is to be marked as spam. and consider privacy: do you want each recipient to see all recipients' addresses?

and as Felix mentioned, make sure spammers can't use your form.

fsb