Error sending email in gmail with PHPmailer

0

I've been using this code for a long time and it worked really well until now it just does not work anymore, neither with outlook nor with gmail.

<?php if($_SERVER['REQUEST_METHOD'] == 'POST' and !empty($_POST['contact_send'])) {
    $contact_name = !empty($_POST['contact_name']) ? true : false;
    $contact_telefone = !empty($_POST['contact_telefone']) ? true : false;
    $contact_email = !empty($_POST['contact_email']) ? true : false;
    $contact_mensagem = !empty($_POST['contact_mensagem']) ? true : false;
    if(!empty($contact_name) and !empty($contact_telefone) and !empty($contact_email) and !empty($contact_mensagem)) {

        date_default_timezone_set('America/Sao_Paulo');
        $datenow = date('d/m/Y', time());
        $timenow = date('H:i', time());

        $from = $_POST['contact_email'];
        $from_name = $_POST['contact_name'];
        $subject = $_POST['contact_name'];
        $msg = '<p>Telefone: ' . $_POST['contact_telefone'] . '</p>
                <p>Email: ' . $_POST['contact_email'] . '</p>
                <p>Data e hora: ' . $datenow . ' | ' . $timenow . '</p>
                <p>Mensagem: ' . $_POST['contact_mensagem'] . '</p>';

        $account = "[email protected]";
        $password = "123";
        $to = "[email protected]";

        require_once("plugins/mail/PHPMailerAutoload.php");

        $mail = new PHPMailer();
        $mail -> IsSMTP();
        $mail -> CharSet = 'UTF-8';
        $mail -> Host = "smtp.gmail.com";
        $mail -> SMTPAuth = true;
        $mail -> Port = 587;
        $mail -> Username = $account;
        $mail -> Password = $password;
        $mail -> SMTPSecure = 'TLS';
        $mail -> From = $from;
        $mail -> FromName = $from_name;
        $mail -> isHTML(true);
        $mail -> Subject = $subject;
        $mail -> Body = $msg;
        $mail -> addAddress($to);

        if(!$mail -> send()) {
            echo $mail -> ErrorInfo; } } } ?>

The message that shows is smtp error with both gmail and outlook, either of the smtp error, but the senha and the usuário are correct.

Someone could help me with both the problem with gmail and outlook and how to use another smtp server eg zohomail or email.com.

I do not care to use gmail or outlook just did not want to modify this code too much because I do not know if they agree, but it is quite functional. In case I believe that it is problem in gmail and outlook that they no longer allow, because it worked and simply stopped.

    
asked by anonymous 22.06.2017 / 17:41

0 answers