Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to send email using PHP SMTP, Failed to send AUTH LOGIN command. Error

I have been trying for last 3 days to resolve the issue and have searched many websites and stackoverflow question but it seems my code is perfect but still it is not working.

function send_email(){
    $this->load->library('email');
    $config['protocol'] = "smtp";
    $config['smtp_host'] = "mail.shadowmail.com.au";
    $config['smtp_port'] = 587;

    $config['smtp_timeout']='30';

    $config['smtp_user'] = "my email id here "; //
    $config['smtp_pass'] = "******";

    $this->email->initialize($config);
    $this->email->set_newline("\r\n");
    $this->email->from("my email id here ", "Test");

    $this->email->to("[email protected]");

    $this->email->subject("heading");
    $this->email->message("heyyyyyyyyyyyy");
    if($this->email->send()){
        echo "done";
    }else{echo "fail";
        show_error($this->email->print_debugger());
    }
}

This error I am getting

220 Sol1-SMEX01.shadowmail.sol1 Microsoft ESMTP MAIL Service ready at Thu, 18 Jan 2018 10:39:18 +1100 

hello: 250-Sol1-SMEX01.shadowmail.sol1 Hello [1.136.213.103]
250-SIZE 41943040
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH GSSAPI NTLM
250-8BITMIME
250-BINARYMIME
250 CHUNKING
Failed to send AUTH LOGIN command. Error: 504 5.7.4 Unrecognized authentication type 
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Date: Thu, 18 Jan 2018 00:39:28 +0100
From: "Test" <my email id was here , i just replaced it with this text>
Return-Path: <my email id was here , i just replaced it with this text>
To: [email protected]
Subject: =?UTF-8?Q?heading?=
Reply-To: <my email id was here , i just replaced it with this text>
User-Agent: CodeIgniter
X-Sender: my email id was here , i just replaced it with this text
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

heyyyyyyyyyyyy

It could be basic question for you but I have been trying for last 3 days and still getting same error. It seems code is ok, might be something is wrong I am unable to identify. My email id and password are correct, I have logged in many times to verify that credentials are working.

like image 611
learner Avatar asked Dec 19 '25 04:12

learner


1 Answers

Codeigniter's email library doesn't seem to support anything but the most basic, insecure authentication method, [LOGIN, basically plaintext] and your SMTP server only supports actual secure authentication methods. [GSSAPI and NTLM]

You need either need to:

  1. Use TLS/SSL.
    • Secure channels usually allow insecure auth, aka LOGIN
    • Unfortunately your host doesn't seems to have it configured, as there's no STARTTLS in the listed capabilities.
  2. Use an email library actually supports one of these methods.

Of these options #1 is your best bet because:

  1. You should neither use nor pay money for an email host that doesn't use SSL in this day and age.
  2. I can't find any PHP email lib advertising support for either GSSAPI or NTLM.

TLDR: You're going to have to yell at your host.

like image 61
Sammitch Avatar answered Dec 21 '25 20:12

Sammitch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!