How to Do Multiple Mailtos in PHP
PHP includes a "mail" function that you can use to send mail to multiple recipients at once. This function takes a recipient list, message and subject parameter, and sends an email message to users from your PHP-enabled Web page. To use the mail function, you must separate the recipients' email addresses using a comma as a delimiter.
Instructions
-
-
1
Right-click the PHP file you want to edit and select "Open With." Click the PHP editor in the list of programs to load the code in your editor.
-
2
Create the variables for your message. The following code sets up the message subject and body:
$body = "This is a message from my PHP page.";
$subject = "Test message.";
-
-
3
Set up the list of recipients. The following code creates a list of recipients for the message:
$to = "myfriend@domain.com, anotherfriend@domain.com, thirdfriend@domain.com";
This example sends a message to three people but you can add as many recipients as you need.
-
4
Send the email. The following code shows you how to use the mail function to send the message:
mail ($to, $subject, $body);
-
1