email using php

Asked

Viewed 73 times

0

People my program is giving a single syntax error on the penultimate line and I do not understand why. Someone help me pf.

<?php
    session_start();
    setlocale(LC_CTYPE,"pt_BR");
    require_once 'PHPMailer/class.phpmailer.php';
    require_once 'PHPMailer/class.smtp.php';

    function sendMail($para,$de,$mensagem,$assunto)
    {
        //dados tmp
        $smtp= "smtp.gmail.com";

        $usuario="[email protected]";
        $senha = "xxxxxxxxxxx";


        $mail = new smtp;
        $mail->Delivery('relay');

        $mail->Relay($smtp,$usuario,$senha,465,'login',true);

        $mail->TimeOut(10);
        $mail->Priority('high');

        $mail->From($de);
        $mail->AddTo($para);
        $mail->Html($mensagem);

            if($mail->Send($assunto))
            {
                echo "alert('Deu certo')";
                $_SESSION['feedback']="Mensagem enviada com sucesso";
                header ("Location: feedback_index.html");
            }
            else
            {
                echo "alert('Deu errado')";
                $_SESSION['feedback'] ="Mensagem não foi enviada";
                header("Location: feedback_index.html");
            }
    }

    $nome = $_POST['nome'];
    $assunto = $_POST['assunto'];
    $email = $_POST['email'];
    $mensagem = $_POST['mensagem'];

    $corpo = 
        '<html>
        <head>
        </head>
        <body>

        Nome:<br>'.$nome.'<p>
        Email:<br>'.$email.'<p>
        Assunto:<br>'.$assunto.'<p>
        Menssagem:<br>'.$mensagem.'<p>      

        </body>
        </html>';

    sendMail('[email protected]',$email,$corpo,$assunto); //está dando erro aqui
?>
  • And what exactly is the error message?

  • is missing . com in your email!

  • @Jonathandetoni I put ". com" and the error continued

  • @Andersoncarloswoss it from the syntax error "ERROR 500".

  • Try using port 587. Often used gmail, Hotmail and the like...

  • @Jonathandetoni still nothing working kkk I’ll try to do again.

  • Ok, so redo and if it generates a different error, or fix edits your question with the solution.

  • In the server error log a more detailed error message should appear.

  • You are testing localmente or on your server?

  • $mail = new smtp; Wouldn’t be new Phpmailer()

  • Add the error message to the question to make it clear to everyone.

  • @Rafaelaugusto using on the server

  • @Leonogueira but I’m using SMTP, why would I put Phpmailer()?

Show 8 more comments
No answers

Browser other questions tagged

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