Enviado em 06/10/2017 - 23:33h
Cara, esse é meu ultimo recurso, já tentei de várias formas resolver esse problema....
Vou mostrar o erro completo: Uncaught Error: Call to undefined method usuarioDAO::enviaremail() in C:\44444444444\00000\88888888\registration.php:253
Stack trace:
#0 {main}
thrown
Vou mostrar o erro completo: Uncaught Error: Call to undefined method usuarioDAO::enviaremail() in C:\44444444444\00000\88888888\registration.php:253
Stack trace:
#0 {main}
thrown
<?phpMeu problema está nessa parte: $mail = $usuarioDAO->enviaremail(); TODO resto funciona numa boa, fiz umas alterações, mas essa linha ficava em dentro do if do 'consultaremail', ele passa por todos os passos, menos o de enviar e-mail.
$POST = filter_input_array(INPUT_POST, FILTER_DEFAULT);
$SERVER = filter_input_array(INPUT_SERVER, FILTER_DEFAULT);
if(isset($POST['idCadastrar'])){
$usuario->setIdNome($POST['idNome']);
$usuario->setIdMail($POST['idMail']);
$usuario->setType_idtype($POST['type_idtype']);
$usuario->setIdSenha($POST['idSenha']);
/*Inicio do reCAPTCHA*/
$secret = "00000000000000000";
$response = null;
$reCaptcha = new ReCaptcha($secret);
if ($POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$SERVER["REMOTE_ADDR"],
$POST["g-recaptcha-response"]
);
}
/*Fim do reCAPTCHA*/
$mail = $usuarioDAO->enviaremail();
if ($response != null && $response->success) {
if (!$usuarioDAO->consultarEmail($POST['idMail'])) {
if($mail == true){
if($usuarioDAO->cadastrar($usuario)){
echo '<script type="text/javascript">';
echo 'setTimeout(function () {';
echo "swal({
title: 'Registration successfully Complete!',
text: 'Confirm the registration in your email, check spam folder!',
timer: 5000,
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false,
onOpen: function () {
swal.showLoading()
}
}).then(
function () {},
function (dismiss) {
if (dismiss === 'timer') {
window.location.href='index.php';
}
}
)";
echo '}, 10);';
echo '</script>';
}
else{
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("OPS...!","There were some errors during registration, reload the page and try again!","error");';
echo '}, 10);</script>';
}
}
else{
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("OPS...!","Failed to send confirmation for your email, try login and resend confimation! If the error recurs, contact dev of the site!","error");';
echo '}, 10);</script>';
}
}
else{
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("OPS...!","Email in use, use other email!","error");';
echo '}, 10);</script>';
}
}
else {
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal("OPS...!","reCAPTCHA detected a spammer, FUCK $%#!","error");';
echo '}, 10);</script>';
exit;
}
}
?>
function enviaremail(usuario $entUsuario) {
try {
$idMail = $entUsuario->getIdMail();
//Create a new PHPMailer instance
$mail = new PHPMailer;
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('0000000000@heliohost.org');
//Set who the message is to be sent to
$mail->addAddress($idMail);
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
if($mail->Send()){
return true;
}
else{
return false;
}
}
catch (PDOException $ex) {
echo "ERRO: {$ex->getMessage()}";
}
} Essa aí é minha função dentro do usuariosDAO.php que está sendo chamada no registration.php e que está resultando no problema, todas as outras funções estão funcionando, tentanto solucionar eu peguei essa estrutura em exemples no github no phpmailer, pq achei que minha lógica para enviar o e-mail estaria errada, porém o erro continua o mesmo.