laminas-mail icon indicating copy to clipboard operation
laminas-mail copied to clipboard

pop3 error message too generic 'last request failed'

Open soleuu opened this issue 2 years ago • 1 comments

Bug Report

Hello,

Pop3 error are generic and hide real error messageand are difficult to debug.

Q A
Version(s) all (since ZF1 to latest laminas version 2.17.0)

Summary

I was having problem with some pop3 authentication and was unable to see real error message without patching some Laminas file. I needed error message send by pop3 server. Laminas doesn't include this message in generated exception.

https://github.com/laminas/laminas-mail/blob/2.17.x/src/Protocol/Pop3.php#L156

in laminas-mail/src/Protocol/Pop3.php:156 it should be added $message and $status (or $result directly) to be able to understand what is the problem.

Exemple of patch :

throw new Exception\RuntimeException('last request failed ['.$status.'].['.$message.']');

Current behavior

error shown was :

[Laminas\Mail\Protocol\Exception\RuntimeException]                                                                             
last request failed

How to reproduce

Connect to some pop3 server with wrong credentials.

Expected behavior

Expect to be able to read server error messages. Here are two exemples of real error messages :

Exemple 1 :

  [Laminas\Mail\Protocol\Exception\RuntimeException]                                                                             
  last request failed [-ERR].[[AUTH] Application-specific password required: https://support.google.com/accounts/answer/185833] 

Example 2 :

  [Laminas\Mail\Protocol\Exception\RuntimeException]                       
  last request failed [-ERR].[[AUTH] Username and password not accepted.]

soleuu avatar Jun 02 '22 11:06 soleuu

@soleuu send a patch: can certainly be included in here :-)

Important: needs an automated test too.

Ocramius avatar Jun 02 '22 11:06 Ocramius