Sendmail () localhost in LOT

3

Friends, I'm able to send mail normally using sendmail () localhost, as follows:

sendmail.ini

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
smtp_ssl=auto
auth_username=meugmail
auth_password=minhasenha

smtp_ssl=tls
tls_certcheck off

php.ini

[mail function]

SMTP = smtp.gmail.com
smtp_port = 465
sendmail_from = meugmail
sendmail_path = "C:\"\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header = Off

At the time of sending I search in a specific table of my bank, where the messages are recorded, and I'll send one by one like this:

$sqlemail = $mysqli->prepare("SELECT id_email, id_msg, id_remetente, id_destinatario, tipo_destinatario, email, assunto, 
                              texto, arquivo_anexo, data FROM tbl_msg_email_temp LIMIT 1");
$sqlemail->execute();
$sqlemail->store_result();

if($sqlemail->num_rows > 0){//Achei emails há serem enviados

    $sqlemail->bind_result($id_email, $id_msg, $id_remetente, $destinatario, $tipo, $email_user, $assunto, $texto, $arquivo_anexo, $data);
    $texto =  nl2br($texto);
    $sqlemail->fetch();
    $sqlemail->close();

So once you have one or more msgs to be sent, I'll send you one by one with the mail () function

if (mail($to, $assuntoHTML, $mensagem, $headers)) {

As I said, this works perfectly, but now I came across the possibility of sending the same msg to several people, and the way it is, I must connect to google every time leaving the process very slow, I would like even connect me once and send the 1,000, 10,000 msgs.

Is this possible?

Thank you.

    
asked by anonymous 26.07.2015 / 18:45

1 answer

1

Based on the response found in SOEN , you could send the same message to several recipients as follows:

while($row = mysql_fetch_array($result))
{
    $addresses[] = $row['address'];
}

$to = implode(", ", $addresses);

$headers .= "BCC: {$to} \r\n";

mail(null, $assuntoHTML, $mensagem, $headers);
    
27.07.2015 / 14:06