Error 500 when using PHPMailer

0

I'm trying to use PHPMailer to send emails but it does not work. Give me 500 error! I use hostinger.com to host my website. Here is the code:

$email = new PHPMailer(true);

            //Using SMTP

            $email->IsSMTP();
            //$email->Host = "in-v3.mailjet.com";
            $email->Host = "aspmx.l.google.com";
            $email->SMTPDebug = 1;
            $email->SMTPAuth = true;
            $email->Host = "smtp.gmail.com";
            $email->Username = $mail;
            $email->Password = $pin;
            $email->SMTPSecure = "ssl";
            $email->Port = 25;

            //Not using SMTP anymore
            try{
            $email->SetFrom (" [email protected]", "Victalium");
            $email->Subject = "Account Activation";
            $email->AddAddress($mail, $user);
            $email->IsHTML(false);

            $email->MsgHTML($mail_msg);
            $email->Send();

            echo "Account created, details:<br>----------------------------------------------------<br>Username: $nick,
                         <br>Email: $mail, <br>Password: $pin.<br>----------------------------------------------------<br> Please check the verification e-mail sent to activate it :)";

            } catch (phpmailerException $e){

                echo "Error during registering, sorry :(";

            }
    
asked by anonymous 29.10.2016 / 22:11

1 answer

0

Modify these lines:

$email->Host

There are 2 lines like this. It should contain only one specifying the SMTP host.

$email->Host = "smtp.google.com" -> caso use gmail

and also this:

$email->Port="25" 

The ports are: 587 if you use tls or 465 if you use ssl in the SMTPSecure directive.

    
30.10.2016 / 02:21