0
Guys I’m trying to send an email to several people inside an array called $destinatario
.
For this I created a function called envia_email
.
But I’m having the following mistake:
Fatal error: Call to a member function AddBCC() on string in
That occurs on the line:
$email->AddBCC($email, $name);
I don’t know what it can be. Follow my code below.
<?php
$destinatario = array(
'[email protected]' => 'Person One',
'[email protected]' => 'Perqweson One',
);
function envia_email($destinatario,$titulo,$texto) {
// Inclui o arquivo class.phpmailer.php localizado na pasta phpmailer
include("Modules/phpmailer/class.phpmailer.php");
// Instanciamos a classe
$email = new PHPMailer();
// Informamos que a classe ira enviar o email por SMTP
$email->isSMTP();
// Configuração de SMTP
$email->Host = "xxxxxxx";
$email->SMTPAuth = true;
$email->SMTPDebug = false;
$email->Port = "587";
$email->Username = "xxxxxxx";
$email->Password = "xxxxxxx";
// Remetente da mensagem
$email->From = "xxxxxxx";
$email->FromName = "xxxxxxx";
// Destinatário do email
foreach($destinatario as $email => $name) {
$email->AddBCC($email, $name);
}
// Iremos enviar o email no formato HTML
$email->IsHTML(true);
// Define a mensagem (Texto e Assunto)
$email->Subject = "$titulo";
$email->Body = "$texto";
// Envia o e-mail
$email->Send();
}
I did not understand very well, have to post an example in the answer?
– Hugo Borges
of course, I put it in the back there.
– Daravahn
hahhahahahahha as I did not pay attention to that hahah, vlw thank you very much
– Hugo Borges
happens hehe :p
– Daravahn