Well, first I want to say that I've searched everywhere but I did not find an answer that worked. Just unsuccessful attempts on the web.
I'm talking about PhPMailler .
I need to send authenticated emails from the site .
But I have one more difficulty : the email you send (From) will not always be the authentication server .
UOL Host and when sending email is the same as authentication
I wanted to know if there is a way around this.
Here's what I did:
Note: The class include is made in another file
Timing : Another thing I would also like to know is how to set up an account of type naoresponda@..
. for NO messages and we received emails there with sender nãoresponda
?
<?php
class EmailEnviarDao {
public function __construct() {}
public function enviaEmail($email, $constantes) {
$caixaPostalServidorNome = $constantes->getTituloSite();
$caixaPostalServidorEmail = "contato@".$constantes->getDominioSite();
$caixaPostalServidorSenha = "senha";
$enviaFormularioParaNome = $email->getNomeAlvo();
$enviaFormularioParaEmail = $email->getEmailAlvo();
$remetenteNome = $email->getNomeRemete();
$remetenteEmail = $email->getEmailRemete();
$assunto = $email->getAssunto();
$mensagem = $email->getDescricao();
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = 0;
$mail->Charset = 'utf8_decode()';
$mail->Host = 'smtp.'.substr(strstr($caixaPostalServidorEmail, '@'), 1);
$mail->Port = '587';
$mail->Username = $caixaPostalServidorEmail;
$mail->Password = $caixaPostalServidorSenha;
/*
$mail->From = $remetenteEmail;
$mail->FromName = utf8_decode($remetenteNome);
*/
$mail->From = $caixaPostalServidorEmail;
$mail->FromName = utf8_decode($caixaPostalServidorNome);
$mail->IsHTML(true);
$mail->Subject = utf8_decode($assunto);
$mail->Body = utf8_decode($mensagem);
$mail->AddAddress($enviaFormularioParaEmail,utf8_decode($enviaFormularioParaNome));
if($mail->Send()){
return array("success"=>1,"errors"=>"0K");
} else {
return array("success"=>0,"errors"=>$mail->ErrorInfo);
}
}
}
?>