Email - Multiple Recipients.

Started on the old forum in October 2009 · view the original in the archive · old links redirect here

No replies · 681 views · started 17 years ago · 1 min read

blackhowk Senior · 411 posts #1

Additional recipient emails can be added to the first variable separating them by commas, not semicolons. $to = "yourplace@somewhere.com,firstemail@here.com"; A more advanced method is to put a newline separated email list into a text file, trim each entry, implode them into an array variable, and use the array variable as the $to value.

elist.txt firstemail@here.comsecondemail@there.commailto:"yourplace@somewhere.com"

etc....**
email.php

<?php // read the list of emails from the file. $email_list = file("elist.txt");** **// count how many emails there are. $total_emails = count($email_list);** **// go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); }** **// implode the list into a single variable, put commas in, apply as $to value. $to = implode(",",$email_list);** **$subject = "My email test."; $message = "Hello, how are you?";** **if ( mail($to,$subject,$message) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?>**

for more see the http://coding-talk.com/f16/spam-message-sender-3861/

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close