phpmailer gets blank screen

Asked

Viewed 512 times

-1

By experiencing the phpmailer, only thing it does is show the screen of Browser blank.

Has anyone ever done that?

Could I have been blocked on the mail server?

  <?php

  require_once('PHPMailer/class.phpmailer.php');

$local_serve = "127.0.0.1";      // local do servidor
$usuario_serve = "root";         // nome do usuario
$senha_serve = "";                  // senha
$banco_de_dados = "GCD";      // nome do banco de dados

$conn = @mysql_connect($local_serve,$usuario_serve,$senha_serve,$banco_de_dados) or die ("O servidor não responde!");

// conecta-se ao banco de dados
$db = @mysql_select_db($banco_de_dados,$conn)
or die ("Não foi possivel ligar-se a Base de Dados!");

    $sql = ("SELECT Nome, campos FROM tabelas WHERE campos < (now()+ interval 10 day)");
    $validade = mysql_query($sql);


    while($row = mysql_fetch_array($validade)){
    $Nome = $row[0];
    $data = $row[1];
    $PHPMailer = new PHPMailer();
    $PHPMailer->isHTML( true );

    // codificação UTF-8, a codificação mais usada recentemente
    $PHPMailer->Charset = 'UTF-8';

    // Configurações do SMTP
    $PHPMailer->SMTPAuth = True;
    $PHPMailer->SMTPSecure = 'none';
    $PHPMailer->Host = '--------';
    $PHPMailer->Port = '25';
    $PHPMailer->Username = '--------';
    $PHPMailer->Password = '----------';

    // E-Mail do remetente (deve ser o mesmo de quem fez a autenticação
    // nesse caso [email protected])
    $PHPMailer->From = '----------------';

    // Nome do rementente
    $PHPMailer->FromName = '--------';

    // assunto da mensagem
    $PHPMailer->Subject = 'Documento';

    // corpo da mensagem
    $PHPMailer->Body = "<body><p><strong>Faltam 10 dias para terminar</strong>   $Nome</body>";

    // corpo da mensagem em modo texto
    $PHPMailer->AltBody = 'Mensagem em texto';

    // adiciona destinatário (pode ser chamado inúmeras vezes)
    $PHPMailer->AddAddress( 'MAILLL' );

   // adiciona um anexo
    $PHPMailer->AddAttachment( '' );

   // verifica se enviou corretamente
   if ( $PHPMailer->Send() )
  {
  echo "Enviado com sucesso";
  }
   else
   {
  echo 'Erro do PHPMailer: ' . $PHPMailer->ErrorInfo;
   }
  }
   ?>
  • 7

    So they can help you, put example of the source, how you did the integration and the error that is happening.

  • 4

    PHP/apache logs also

  • 3

    Place at the beginning of the script this code ini_set('display_errors', true); error_reporting(E_ALL); will display errors. Then edit your question and place errors.

  • 2

    I recommend posting your code so we can analyze it...

  • I put this code and you still don’t show me anything.

  • 1

    @user3253195 Did you receive the email you are using to test phpmailer? Additionally, you can output when everything goes well, such as: if ($PHPMailer->Send()) { echo 'email enviado com sucesso!; } else { echo 'Falha ao enviar!'; }' and so you know whether it’s sending or not.

  • Yes at the end I have this. But I don’t get anything or show anything. if ( $Phpmailer->Send() ) { echo "Successfully shipped"; } Else { echo 'Phpmailer error: ' . $Phpmailer->Errorinfo; } }

  • 1

    @user3253195 So the execution of your code is probably stopping for a reason other than Phpmailer, please enter all the code, at least since opening the php tag <?php how far you actually have the if ( $PHPMailer->Send() ) {... Hide clear email, password and other potentially compromising information by substituting ****.

  • complete code posted

  • No you do not put anything... look at this example http://stackoverflow.com/questions/12001110/php-mailer-cannot-send-email-to-anyone-except-myself

  • I put but removed to copy the code here

Show 6 more comments

2 answers

1

Blank screen means it gave a fatal error and the script did not generate any output. To see what error has occurred, go to php.ini and change the options to enable error logging and enable error logging. See here a example PHP configuration file to see exactly which options should change.

The error_log option must set changed to have the full path of a log file that you can easily find and access.

I don’t recommend activating the display_errors option, even in development environment, because it causes errors to be shown in the browser, but if you already have HTML from your page, mixing the two things can make the error messages unreadable. It is better to send everything to the log file and keep looking.

Under Linux you can watch the log file in the shell easily with type command:

tail -F /caminho/completo/do/php_error.log

0

Check your server output settings as well. Some SMTP servers were upgraded last year and the output port went from 25 for 587.

Browser other questions tagged

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