What code I should do change in this PHP script to send one email to more than 20 email addresses?
Your
$email_to = "address@one.com, address@two.com, address@three.com"
Needs to be a comma delimited list of email adrresses.
mail($email_to, $email_subject, $thankyou);
This worked for me,
$recipient_email = 'sales@abc.com,support@xyz.com';
$success = mail($recipient_email, $subject, $body, $headers);
Something like this:
mail("john@doe.com , marry@mail.com , frank@domain.com", "Test e-mail", "Hi, this is a test message!");
http://myphpform.com/php-form-multiple-recipients.php
Programmatically sending an submitted form to multiple email address is a possible thing, however the best practice for this is by creating a mailing list. On the code the list address will be place and any change or update on email addresses to the recipients list can be done without changing in the code.
It is very bad practice to send all email addresses to all recipients; you should use Bcc (blind carbon copies).
$from = "myname@mymail.com";
$recipList = "mailaddress1,mailaddress2,etc";
$headers = "MIME-Version: 1.0\nContent-type: text/html; charset=utf-8\nFrom: {$from}\nBcc: {$recipList}\nDate: ".date(DATE_RFC2822);
mail(null,$subject,$message,$headers); //send the eail
Just separate them by comma, like $email_to = "youremailaddress@yourdomain.com, emailtwo@yourdomain.com, John Doe <emailthree@example.com>"
.