Todas las respuestas son grandes. He aquí un caso de ejemplo el uso dirección de agregar múltiples: La capacidad de agregar tanto de correo electrónico que desee en la demanda con un formulario web:
See it in action with jsfiddle here (excepto el procesador php)
### Send unlimited email with a web form
# Form for continuously adding e-mails:
<button type="button" onclick="emailNext();">Click to Add Another Email.</button>
<div id="addEmail"></div>
<button type="submit">Send All Emails</button>
# Script function:
<script>
function emailNext() {
var nextEmail, inside_where;
nextEmail = document.createElement('input');
nextEmail.type = 'text';
nextEmail.name = 'emails[]';
nextEmail.className = 'class_for_styling';
nextEmail.style.display = 'block';
nextEmail.placeholder = 'Enter E-mail Here';
inside_where = document.getElementById('addEmail');
inside_where.appendChild(nextEmail);
return false;
}
</script>
# PHP Data Processor:
<?php
// ...
// Add the rest of your $mailer here...
if ($_POST[emails]){
foreach ($_POST[emails] AS $postEmail){
if ($postEmail){$mailer->AddAddress($postEmail);}
}
}
?>
Entonces, ¿qué se básicamente consiste en generar un nuevo cuadro de texto de entrada en cada clic con el nombre "correos electrónicos []".
El [] añadido al final lo convierte en una matriz cuando se publica.
A continuación, vamos a través de cada elemento de la matriz con "foreach" en el lado PHP añadiendo el:
$mailer->AddAddress($postEmail);
PHPMailer puede ahora (mayo de 2015) manejar este tipo de cadena de dirección a través de una función de análisis. Ver [esta respuesta] (http://stackoverflow.com/a/30377848/333340) – Synchro