Phpmailer Internal Server error

Asked

Viewed 803 times

0

It had this function running on the localhost perfectly, and in all tests it sent the emails correctly but after I put it on my server it no longer sends the emails and gives the error "500 Internal Server error" does anyone know what the problem is? thank you

function SendMail($subject, $message, $to, $toName){

$mail = new PHPMailer();

// Servidor
$mail->isSMTP();
$mail->Host       = 'xxxxxxxxx';
$mail->SMTPAuth   = true;
$mail->Username   = 'xxxxxxx';
$mail->Password   = 'xxxxxx';
$mail->Port       = xxxx;
$mail->SMTPSecure = false;

// Remetente
$mail->From       = 'xxxxx';
$mail->FromName   = 'xxxx';

// Destino
$mail->addAddress($to, $toName);

// Dados da Messagem
$mail->isHTML(true);
$mail->CharSet    = 'utf-8';
$mail->WordWrap   = 70;

// Mensagem
$mail->Subject    = $subject;
$mail->Body       = $message;
$mail->Altbody    = strip_tags($message);

return $mail->Send();
}

Note: xxx= are my personal data that I did not put here but are correct on my server.

  • Do you know if sending emails is enabled on the remote server? You have access to the application logs?

  • yes are enabled, it’s all right, before I used the same settings of sending email on my remote server to the localhost and the emails were sent, after I uploaded the files to the server no longer gives.

  • What changed from before to after?

  • in relation to the server code or response? The code is the same because my remote server’s email sending settings are the same

  • Add these two lines at the beginning of the file that calls its function, ini_set('display_errors', true);error_reporting(E_ALL); if you have any error it will hablitar the display. Put tbm the phpmailer debug, $mail->SMTPDebug = 1;

  • did not modify anything... the page loads about 30 seconds and then displays the message "Internal Server Error"

  • 1

    Now it returned error "SMTP ERROR: Failed to connect to server: Connection timed out (110) 2015-01-08 17:17:12 SMTP connect() failed."

Show 2 more comments

1 answer

0


I was using phpmailer recently and suffered the same problem as yours, I have two tips to pass you:

1° check that the openssl php module is enabled, phpmailer needs it

2° if it is Gmail,Hotmail,Yahoo use port 587.

Browser other questions tagged

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