Envio de email Marketing Usando PHPmailer e Mandrill(Mailchimp)
Pessoal queria saber se alguém já fez isso, por que estou tentando autenticar no servidor STMP Mandrill porem o email não é enviado.
Alguém conhece ou já utilizou esse serviço.
<?php
echo '<meta charset="UTF-8">';
require_once '../CTR/emailCTR.php';
require_once '../DTO/emailDTO.php';
require_once 'email/class.phpmailer.php';
$emailDTO = new emailDTO();
$emailCTR = new emailCTR();
$emailDTO->setNome($_POST['nome']);
$emailDTO->setEmail($_POST['email']);
$emailDTO->setStatus(0);
$mail = new PHPMailer();
$mail->IsSMTP(); // Define que a mensagem será SMTP
$mail->Host = "smtp.mandrillapp.com"; // Endereço do servidor SMTP
$mail->Port = "587";
$mail->SMTPAuth = true; // Autenticação
$mail->Username = 'b...@gmail.com'; // Usuário do servidor SMTP
$mail->Password = '1g...q7i...A'; // Senha da caixa postal utilizada
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Priority = 1;
$mail->IsHTML(true); // Define que o e-mail será enviado como HTML
$mail->CharSet = 'utf-8'; // Charset da mensagem (opcional)
$mail->From = "noreplay@elitenaweb.com.br";
$mail->FromName = "Elite na Web";
if (isset($_POST['cad'])) {
$listar[] = new emailDTO();
$emailDTO->setOp(2);
$listar = $emailCTR->pesquisarEmail($emailDTO);
if ($listar[0]->getEmail() == "") {
$mail->AddAddress($_POST['email'], $_POST['nome']);
$mail->AddAddress($_POST['email']);
$mail->Subject = "Seja Bem Vindo ao Elite na Web"; // Assunto da mensagem
$mail->Body = '<html>
<body>
<font face=Verdana size=1>
<div style="background: #999; width: 100%; padding: 20px;"><center><img src="http://elitenaweb.com.br/VIEW/img/logo.png" width="300"></center></div><br>
<br>
<center><b>Nós do Elite na Web agradecemos a sua visita!</b></center><br>
</font>
</body>
</html>';
$mail->AltBody = '<img src="http://elitenaweb.com.br/VIEW/img/logo.png" width="300">
Nós do Elite na Web agradecemos a sua visita!\r\n
';
$emailDTO->setOp(1);
if ($emailCTR->modificarEmail($emailDTO)) {
echo "<script>alert('Email foi cadastrado sucesso.');
location.href = '../VIEW/';</script>";
exit;
} else {
echo "<script>alert('Erro ao cadastrar Email.');
location.href = '../VIEW/';</script>";
}
} else {
echo "<script>alert('Email já cadastrado.');
location.href = '../VIEW/';</script>";
}
}
if (isset($_POST['env'])) {
$assunto = $_POST['assunto'];
$msg = $_POST['msg'];
$imagem = $emailCTR->trataFoto($_FILES['img'], $foto_ant, $largura, $altura, $txt);
$email[] = new emailDTO();
$emailDTO->setOp(1);
$email = $emailCTR->pesquisarEmail($emailDTO);
if ($imagem != null) {
$imgtexto = 'Visualize a imagem a baixo!';
}
echo 'entrei1';
foreach ($email as $envia) {
$mail->AddAddress($envia->getEmail(), $envia->getNome());
$mail->AddAddress($envia->getEmail());
$mail->Subject = $assunto; // Assunto da mensagem
$mail->Body = '<html>
<body>
<font face=Verdana size=1>
<div style="background: #999; width: 100%; padding-top: 10px; padding-botton: 10px;"><center><img src="http://elitenaweb.com.br/VIEW/img/logo.png" width="300"></center></div><br>
<br>
<center><b>' . $assunto . '</b> ' . $imgtexto . '</center><br/>
<center><img src="http://elitenaweb.com.br/VIEW/img_email/' . $imagem . '" style="width: 100%;"></center>
<center><b>Acesse nosso site e fique por dentro das ultimas noticias!</b></center><br/>
</font>
</body>
</html>';
$mail->AltBody = '<img src="http://elitenaweb.com.br/VIEW/img/logo.png" width="300">
Nós do Elite na Web agradecemos a sua visita!\r\n';
$ok = $mail->Send();
if ($ok) {
echo 'ok';
} else {
echo 'fail';
}
}
}
if (isset($_POST['contato'])) {
$assunto = $_POST['assunto'];
if ($_POST['nome'] != null) {
$nome = $emailDTO->getNome();
} else {
$nome = $_POST['nome'];
}
if ($_POST['setor'] == 0) {
$setor = 'Contato';
} else if ($_POST['setor'] == 2) {
$setor = 'Compra de Anuncios';
} else {
$setor = 'Sugestão de Materia';
}
$mail->From = $_POST['email'];
$mail->FromName = $nome;
$mail->AddAddress('contato@elitenaweb.com.br', 'Contato Site');
$mail->AddAddress('contato@elitenaweb.com.br');
$mail->Subject = $assunto; // Assunto da mensagem
$mail->Body = '<html>
<body>
<font face=Verdana size=1>
<div style="background: #999; width: 100%; padding-top: 10px; padding-botton: 10px;"><center><img src="http://elitenaweb.com.br/VIEW/img/logo.png" width="300"></center></div><br>
<br>
<b>Nome:' . $nome . '</b><br/>
<b>Telefone:' . $_POST['tel'] . '</b><br/>
<b>Email:' . $_POST['email'] . '</b><br/>
<b>Setor:' . $setor . '</b><br/>
<b>Mensagem:' . $_POST['msg'] . '</b><br/>
<center><b>Acesse nosso site e fique por dentro das ultimas noticias!</b></center><br/>
</font>
</body>
</html>';
$mail->AltBody = 'Nome:' . $nome . '
Telefone:' . $_POST['tel'] . '\r\n
Email:' . $_POST['email'] . '\r\n
Setor:' . $setor . '\r\n
Mensagem:' . $_POST['msg'] . '\r\n
Acesse nosso site e fique por dentro das ultimas noticias!\r\n';
$ok = $mail->Send();
}
$mail->ClearAllRecipients();Discussão (2)
Carregando comentários...