laminas / laminas-mail

Provides generalized functionality to compose and send both text and MIME-compliant multipart e-mail messages
https://docs.laminas.dev/laminas-mail/
BSD 3-Clause "New" or "Revised" License
94 stars 64 forks source link

pop3 error message too generic 'last request failed' #187

Open soleuu opened 2 years ago

soleuu commented 2 years ago

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.]
Ocramius commented 2 years ago

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

Important: needs an automated test too.