Y
Y
Yrets1692021-03-24 10:47:24
PHP
Yrets169, 2021-03-24 10:47:24

How to send messages to recipients via phpmailer in mass mailing?

Good afternoon, there is a script that makes mass mailing of letters to addresses.
Letters are sent through an array that forms a list of email and name (username), letters are received by email , but in the contents of the letter, all recipients receive the same name .

sending by mail

$combined = array();
foreach($_POST['options'] as $index => $options) {
    if(!array_key_exists($index, $_POST['options2'])) {
        throw OutOfBoundsException();
    }
    $combined = array(
        'email'  => $options,
        'name' => $_POST['options2'][$index]
    );
    $mail->msgHTML("<html><body>
                <h1>Здравствуйте! ".$combined['name']."</h1>
                <p>Это тестовое письмо.</p>
                </html></body>");
   $mail->AddBCC($combined['email']);
}


var_damp($combined);
array(2) { ["email"]=> string(14) "[email protected]" ["name"]=> string(12) "Иванов" } array(2) { ["email"]=> string(13) "[email protected]" ["name"]=> string(3) "Doe" } array(2) { ["email"]=> string(7) "[email protected]" ["name"]=> string(21) "Вася Пупкин" }


How to send a specific name to a specific email ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question