500 error when using Phpmailer

Asked

Viewed 716 times

0

I’m trying to use Phpmailer to send emails but it doesn’t work. It gives me error 500! 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 :(";

            }

1 answer

0


Modify these lines:

$email->Host

Has 2 lines like this. Must 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.

  • Thanks for the help ;)

Browser other questions tagged

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