automatic email response with phpmailer

1

Talk about it!

I'm using phmailer to send mail, this is working fine on sending, but I'd like to know how to make an automatic response through phpmailer itself.

Could anyone give me a hint?

EDITED

FOR THOSE WHO HAVE THE SAME DOUBT, FOLLOW THE SOLUTION:

<?php

// Inclui o arquivo class.phpmailer.php localizado na pasta phpmailer
require("phpmailer/class.phpmailer.php");
require("../includes/cookie.class.php");

if (!isset($_GET['nome'])) exit('Por favor informe o seu nome');
if (!isset($_GET['mail'])) exit('Por favor informe o seu email');
if (!isset($_GET['msge'])) exit('Por favor preencha o campo mensagem');
/*if (isset($_GET['g-recaptcha-response'])) {
    $captcha_data = $_GET['g-recaptcha-response'];
}
if (!$captcha_data) {
    echo "<script>alert('Por favor, confirme o captcha.')</script>";
    header("Location: contato");
    exit;
}
*/
$nome = $_GET['nome'];
$mail = $_GET['mail'];
$fone = $_GET['fone'];
$var_msge = $_GET['msge'];

Cookie::Set('nome', nome, Cookie::ThirtyDays);
Cookie::Set('email', mail, Cookie::ThirtyDays);
Cookie::Set('fone', fone, Cookie::ThirtyDays);

$body = "<table style='background: #ccc; width: 100%;' cellpadding='10' border='1' >";
$body = $body ."<tr>";
$body = $body ."<th>NOME</th>";
$body = $body ."<th>E-MAIL</th>";
$body = $body ."<th>TELEFONE</th>";
$body = $body ."<th>MENSAGEM</th>";
$body = $body ."</tr>";
$body = $body ."<tr>";
$body = $body ."<td>".$nome."</td>";
$body = $body ."<td>".$mail."</td>";
$body = $body ."<td>".$fone."</td>";
$body = $body ."<td>".$msge."</td>";
$body = $body ."</tr>";
$body = $body ."</table>";

// Inicia a classe PHPMailer
$mail = new PHPMailer();

// Define os dados do servidor e tipo de conexão
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->IsSMTP(); // Define que a mensagem será SMTP
$mail->Host = "smtp.site.com"; // Endereço do servidor SMTP
$mail->Port = '587';
$mail->SMTPAuth = true; // Usa autenticação SMTP? (opcional)
$mail->Username = '[email protected]'; // Usuário do servidor SMTP
$mail->Password = 'SENHA'; // Senha do servidor SMTP

// Define o remetente
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->From = "[email protected]"; // Seu e-mail
$mail->FromName = "RESPOSTA"; // Seu nome

// Define os destinatário(s)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->AddAddress('[email protected]', 'X');


// Define os dados técnicos da Mensagem
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->IsHTML(true); // Define que o e-mail será enviado como HTML
$mail->CharSet = 'UTF-8'; // Charset da mensagem (opcional)

// Define a mensagem (Texto e Assunto)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->Subject  = "CONTATO"; // Assunto da mensagem
$mail->Body = $body;
$mail->AltBody = "Para visualizar a mensagem utilize um cliente de email compativel com HTML!";

// Define os anexos (opcional)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//$mail->AddAttachment("c:/temp/documento.pdf", "novo_nome.pdf");  // Insere um anexo

// Envia o e-mail
$enviado = $mail->Send();

// Limpa os destinatários e os anexos
$mail->ClearAllRecipients();
$mail->ClearAttachments();

// Exibe uma mensagem de resultado
if ($enviado) {

$body = "<table align='center' style='font-size: 18px; color: #fff; background: #000; width: 60%; text-align: center; padding: 30px; margin: 0 auto;' cellpadding='10' border='0' >";
$body = $body ."<tr>";
$body = $body ."<td>Olá <b>".$nome."</b>! 
                        Recebemos a sua proposta, 
                        dentro do prazo de 60min em horário comercial retornaremos o contato.<br><br><br><br><br>
                        Atenciosamente<br><br>
                        <img src='http://site.com/img/logo.png' width='100' alt='logo' /><br><br>
                        Telefone<br>
                        E-mail<br>
                        Etc...<br>
                        </td>";
$body = $body ."</tr>";
$body = $body ."</table>";

// Define os dados do servidor e tipo de conexão
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->IsSMTP(); // Define que a mensagem será SMTP
$mail->Host = "smtp.site.com"; // Endereço do servidor SMTP
$mail->Port = '587';
$mail->SMTPAuth = true; // Usa autenticação SMTP? (opcional)
$mail->Username = '[email protected]'; // Usuário do servidor SMTP
$mail->Password = 'SENHA'; // Senha do servidor SMTP

// Define o remetente
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->From = "[email protected]"; // Seu e-mail
$mail->FromName = "CONTATO DO SITE.COM."; // Seu nome

// Define os destinatário(s)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->AddAddress($mail, $nome);


// Define os dados técnicos da Mensagem
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->IsHTML(true); // Define que o e-mail será enviado como HTML
$mail->CharSet = 'UTF-8'; // Charset da mensagem (opcional)

// Define a mensagem (Texto e Assunto)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->Subject  = "auto-reply"; // Assunto da mensagem
$mail->Body = $body;
$mail->AltBody = "Para visualizar a mensagem utilize um cliente de email compativel com HTML!";

// Define os anexos (opcional)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//$mail->AddAttachment("c:/temp/documento.pdf", "novo_nome.pdf");  // Insere um anexo

// Envia o e-mail
$mail->Send();

// Limpa os destinatários e os anexos
$mail->ClearAllRecipients();
$mail->ClearAttachments();


header('Location: proposta-enviada');
  die();
} else {
echo "Não foi possível enviar o e-mail.<br /><br />";
echo "<b>Informações do erro:</b> <br />" . $mail->ErrorInfo;
}

?>
    
asked by anonymous 18.08.2015 / 22:56

0 answers