Michael Fayez's avatar

hostinger email

I got this error

Failed to authenticate on SMTP server with username "[email protected]" using the following authenticators: "LOGIN", "PLAIN". Authenticator "LOGIN" returned "Expected response code "235" but got code "535", with message "535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6".". Authenticator "PLAIN" returned "Expected response code "235" but got code "535", with message "535 5.7.8 Error: authentication failed: UGFzc3dvcmQ6".".

Here is my .env

MAIL_MAILER=smtp
MAIL_HOST=smtp.hostinger.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"
0 likes
2 replies
LaryAI's avatar
Level 58

The error message you're seeing indicates that the SMTP server is rejecting the authentication details provided. This could be due to a number of reasons, such as incorrect username or password, incorrect server settings, or the server requiring additional security measures.

Here are some steps you can take to troubleshoot and resolve the issue:

  1. Double-check Credentials: Ensure that the MAIL_USERNAME and MAIL_PASSWORD are correct. You should verify these details with your email service provider.

  2. Use Correct Ports and Encryption: Make sure that the MAIL_PORT and MAIL_ENCRYPTION settings match what Hostinger recommends for SMTP. As of my knowledge cutoff in 2023, these settings seem correct for TLS encryption, but it's always good to double-check in case they have changed.

  3. App Password: If you have two-factor authentication (2FA) enabled for your email account, you may need to use an app-specific password instead of your regular password.

  4. Allow Less Secure Apps: Some email providers require you to enable an option to allow less secure apps to access your email account. This is less common with business accounts, but it's worth checking if Hostinger has such a setting.

  5. Clear Cache: If you are using a framework like Laravel, after changing the .env file, you may need to clear the configuration cache. You can do this by running the following command in your terminal:

php artisan config:cache
  1. Test with a Simple Script: Sometimes, testing with a simple PHP script to send an email can help isolate the issue. Here's an example using PHPMailer:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    $mail->isSMTP();
    $mail->Host = 'smtp.hostinger.com';
    $mail->SMTPAuth = true;
    $mail->Username = '[email protected]';
    $mail->Password = 'your_password';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;

    $mail->setFrom('[email protected]', 'Mailer');
    $mail->addAddress('[email protected]', 'Joe User');

    $mail->isHTML(true);
    $mail->Subject = 'Test Mail Subject!';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

Replace 'your_password' with the actual password and '[email protected]' with the recipient's email address.

If none of these steps resolve the issue, you may need to contact Hostinger support for assistance, as the problem could be on their end or there might be additional settings or restrictions that are not documented.

RafaelFerraria's avatar

@LaryAI Tenho o mesmo erro usando o email da hostinger mas usando o email da hospedagem da amen funciona perfeitamente

Please or to participate in this conversation.