I can’t email with Phpmailer on the server

Asked

Viewed 587 times

0

require 'phpmailer/class.phpmailer.php';
require 'phpmailer/class.smtp.php';

$mail = new PHPMailer();
$mail->setLanguage('pt');

$from = '[email protected]';
$fromName = 'EmailServidor';

$host       = 'servidor.one.com';
$username   = '[email protected]';
$password   = '123456';
$port       = 587;
$secure     = false;

$mail->isSMTP();
$mail->Host         = $host;
$mail->SMTPAuth     = true;
$mail->Username     = $username;
$mail->Password     = $password;
$mail->Port         = $port;
$mail->Secure       = $secure;

$mail->From         = $from;
$mail->FromName     = $fromName;

$mail->addAddress('[email protected]', 'Usuario');

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

$mail->Subject = 'Confirmação de Cadastro';
$mail->Body    = 'Email de teste.';
$mail->AltBody = 'Email de teste.';

$send = $mail->Send();

if($send)
    echo 'E-mail enviado com sucesso!';
else
    echo 'Error: '.$mail->ErrorInfo;

So I did the tests on the localhost with Xampp and it worked, but when I went to test on the One.com server, it did not send the message and also showed no errors. Any idea what it might be?

  • Is the sender email(from) correct, exists on the server? , has servers that have security policies that only accept the sending of email that exist, other servers you can put any email in the from that passes, have to check also the sending ports of the server if they are not other.

  • 1
  • Also checks if your provider does not require sending of smtp ssl : $mail->Smtpsecure = "ssl"

  • But I think the problem is on the server, because when I use the script on the localhost it works, already on the server it simply does not return anything, it is loading infinitely.

  • What version of php on your @Ingi server?

  • 5.6, sorry the delay was without internet for a few days @Guilherme Nascimento

Show 1 more comment
No answers

Browser other questions tagged

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