E-mail using the Phpmailer class

Asked

Viewed 45 times

0

I got the following form on my page index.php :

<form id="form-contato" method="post" action="email.php">
    <div>
        <div class="row">
            <div class="6u 12u(mobile)">
                <input type="text" name="name" id="nome" placeholder="Nome" />
            </div>
            <div class="6u 12u(mobile)">
                <input type="text" name="email" id="email" placeholder="Email" />
            </div>
        </div>
        <div class="row">
            <div class="12u">
                <input type="text" name="subject" id="assunto" placeholder="Assunto" />
            </div>
        </div>
        <div class="row">
            <div class="12u">
                <textarea name="message" id="mensagem" placeholder="Mensagem"></textarea>
            </div>
        </div>
        <div class="row 200%">
            <div class="12u">
                <ul class="actions">
                    <li><input type="submit" value="Enviar mensagem"/></li>
                    <li><input type="reset" value="Limpar campos" class="alt" /></li>
                </ul>
            </div>
        </div>
    </div>
</form>

I created an email.php page to send the completed data in the index.php form:

    <?php

require_once("phpmailer.php");
error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set('America/Sao_Paulo');
$ip = getenv("REMOTE_ADDR");
// variáveis que guardam os dados vindo do form
$nome = utf8_decode($_POST['nome']);
$email = utf8_decode($_POST['email']);
$assunto = utf8_decode($_POST['assunto']);
$mensagem = utf8_decode($_POST['mensagem']);

$Email = new PHPMailer();
$Email->SetLanguage("br");
$Email->IsMail();
$Email->IsHTML(true);

$Email->From = $email;
$Email->FromName = $nome;
$Email->AddAddress("[email protected]");
$Email->Subject = $assunto;
$Email->AddBcc($email);

if(!$Email->Send()) {
    echo "Erro: " . $Email->ErrorInfo;
} else {
    echo "Mensagem enviada!";
}

But the email is not being sent. What is missing ?

1 answer

0

Try using this setting...
In mine it’s working...
NOTE: It is set to gmail

<?php
require_once '../PHPMailer/PHPMailerAutoload.php';

  $mail = new PHPMailer;
  $mail->isSMTP();
  $mail->CharSet = "utf8";
  //$mail->SMTPDebug = 3;
  $mail->Host ='smtp.gmail.com';
  $mail->SMTPAuth = true;
  $mail->Username = '[email protected]';
  $mail->Password = 'suasenha';
  $mail->SMTPSecure = 'tls'; //ssl
  $mail->Port = 587; //465
  $mail->FromName = "De";
  $mail->isHTML(true);
  $mail->AddReplyTo("Emailcasoforresponder", "Nome");
  $mail->addAddress('[email protected]', 'nomeDestinario'); //E-mail destinario
  $mail->Subject = "Assunto";
  $mail->Body = "Mensagem";

  if(!$mail->Send()){       
    return 'Erro ao enviar e-mail: '.$mail->ErrorInfo;
  }else{
    return TRUE;
  }
  • In phpmailer q I downloaded did not come this class Phpmailerautoload

  • 1

    @Raphaelpradodeoliveira I downloaded the last version... After downloading unzip inside your project and include the file Phpmailerautoload.php Follow the link: https://github.com/PHPMailer/PHPMailer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.