ProtonMail / proton-bridge

Proton Mail Bridge application
GNU General Public License v3.0
1.17k stars 157 forks source link

MAIL command doesn't support AUTH Parameter #46

Closed smoores-dev closed 3 years ago

smoores-dev commented 4 years ago

Some mail clients (e.g. KMail and E-mailRelay) include parameters such as BODY= and AUTH= in the MAIL command in addition to the primary FROM: parameter. When a client sends a MAIL command with an AUTH parameter, protonmail-bridge returns a 501 code.

Expected Behavior

AUTH parameters should be handled per https://tools.ietf.org/html/rfc4954#section-5. This has been fixed upstream in go-smtp.

Current Behavior

Both myself and another user (see https://www.reddit.com/r/ProtonMail/comments/evadaz/need_help_setting_up_outgoing_with_kmail/ for the other report) are experiencing the following interaction:

Example command from the client:

MAIL FROM:<example@example.com> BODY=7BIT AUTH=<username>

Response from protonmail-bridge:

501 Was expecting MAIL arg syntax of FROM:<address>

Possible Solution

Possibly as simple as pulling in the latest go-smtp. It looks like protonmail-bridge uses an old fork (circa 2018) that has different handling behavior for the optional mail parameters.

I'm actually a little unsure about exactly what's happening here though; reading through the conn.go file in the fork, it's unclear to me how MAIL FROM:<example@example.com> AUTH=<username> would result in the error above. I'm sure I'm missing something :P.

When I modified E-mailRelay (http://emailrelay.sourceforge.net/index.html#) to stop appending the AUTH and BODY parameters (commented out lines 190-201 in src/gsmtp/gsmtpclientprotocol.cpp in version 2.1), protonmail-bridge stopped returning a 501 and emails started going through.

Steps to Reproduce

I haven't created a minimal repro with telnet, but I can try that if it would be helpful.

Context (Environment)

Trying to send an email to protonmail-bridge from an email client.

horejsek commented 4 years ago

Thanks for the report! We have added update to latest go-smtp in our backlog (reference GODT-202).

hugbubby commented 4 years ago

@SMores

I'm actually a little unsure about exactly what's happening here though; reading through the conn.go file in the fork, it's unclear to me how MAIL FROM:example@example.com AUTH= would result in the error above. I'm sure I'm missing something :P.

In our case, it didn't. I've forked this application's library so that I can implement a temporary fix and I'm debugging it now, but I'm fairly sure that the real problem is an empty FROM:<> address.

ghostwalkerj commented 4 years ago

@SMores

I'm actually a little unsure about exactly what's happening here though; reading through the conn.go file in the fork, it's unclear to me how MAIL FROM:example@example.com AUTH= would result in the error above. I'm sure I'm missing something :P.

In our case, it didn't. I've forked this application's library so that I can implement a temporary fix and I'm debugging it now, but I'm fairly sure that the real problem is an empty FROM:<> address.

@SMores

I'm actually a little unsure about exactly what's happening here though; reading through the conn.go file in the fork, it's unclear to me how MAIL FROM:example@example.com AUTH= would result in the error above. I'm sure I'm missing something :P.

In our case, it didn't. I've forked this application's library so that I can implement a temporary fix and I'm debugging it now, but I'm fairly sure that the real problem is an empty FROM:<> address.

I'd be keen to test your fix when you are ready. I was pretty excited to finally get a client to work the with bridge until I hit this showstopper.

smoores-dev commented 4 years ago

@jiyosub sorry to have missed this. I actually wrote a blog post about solving this problem for my local setup, though I can't promise it will help in all cases: https://smoores.dev/post/smtp_conversation/#uphill-from-here.

@hugbubby In my case, I was watching the SMTP communication with tcpdump, and the FROM field was definitely filled in with my email address (correctly formatted, too!). Here's an example of what I was seeing:

$ sudo tcpdump -i lo -A
Bridge > 220 127.0.0.1 ESMTP Service Ready
EmailRelay > EHLO debian.r710
Bridge > 250-Hello debian.r710
Bridge > 250 AUTH PLAIN LOGIN
EmailRelay > AUTH PLAIN [auth token redacted]
Bridge > 235 Authentication succeeded
EmailRelay > MAIL FROM:<email@example.com> BODY=7BIT AUTH=<email@example.com>
Bridge > 501 Was expecting MAIL arg syntax of FROM:<address>
wilderjds commented 3 years ago

Any updates on this? I am still unable to have kmail work with the bridge

andrzejsza commented 3 years ago

@wilderjds we've just upgraded to upstream go-smtp. the release should be out in a few days - will keep you posted.

wilderjds commented 3 years ago

oh that's great; As a matter of fact I just did some further debugging. It seems that kmail sends an empty sender, that is

MAIL FROM: <>

Would the upstream merge have fixed this issue as well?

Edit: It appears it does not. I just built the master branch and emails still get bounced

andrzejsza commented 3 years ago

@wilderjds can you try with 1.5.4? should be all good.