emersion / go-imap

📥 An IMAP library for clients and servers
MIT License
2.07k stars 292 forks source link

Support IMAP4 ID command (RFC 1971) #598

Closed quzhi1 closed 3 months ago

quzhi1 commented 6 months ago

Can you support IMAP ID command as specified in RFC 1971? https://www.rfc-editor.org/rfc/rfc2971.html

emersion commented 6 months ago

Right… I've been holding off on that one because I think it's harmful: it enables clients and servers to implement implementation-specific workarounds instead of following the standard.

Can you explain your use-case?

quzhi1 commented 6 months ago

The use case is Yahoo. Yahoo advise users to use id command to identify themselves. Here is the quote:

Client Indentification

The Verizon Media IMAP server supports the IMAP ID command https://www.ietf.org/rfc/rfc2971.txt to gather statistics and facilitate troubleshooting. An IMAP client connecting to the Verizon Media servers should issue the ID command with the following attributes: NAME, VERSION, OS, OS-VERSION.

NAME should be the partner name or the ID assigned during the approval process. example: "name" "iPhone Mail" "name" "com.android.email" "name" "yahoo.com"

VERSION is the version of that client. It's useful when watching for changes in behavior OS & OS-VERSION are additional info for determining client environment specific issues.

A full ID command looks like this: C: a007 ID ("name" "<'client name'>" "version" "<'client version'>" "os" "<'client os'>" "os-version" "<'client os version'>")

https://developer.yahooinc.com/imap-smtp/

quzhi1 commented 6 months ago

It is also documented here: https://senders.yahooinc.com/developer/documentation/#imap-features

x0st commented 6 months ago

@quzhi1 https://github.com/emersion/go-imap/pull/601

emersion commented 6 months ago

Right, so it's a recommendation from Yahoo, but is there any real gain for clients which use the ID extension?

quzhi1 commented 6 months ago

Right, so it's a recommendation from Yahoo, but is there any real gain for clients which use the ID extension?

@emersion Yes. I reached out to Yahoo, and they said if I set IMAP ID, they can detect the origin of the IMAP request, and can raise the rate limit. Also, if we do not pass the IMAP ID, they can potentially lock the Yahoo account if they see too many IMAP connections.

quzhi1 commented 6 months ago

This is the email Yahoo sent us. Basically they ask me to pass IMAP ID as part of their IMAP agreement:

Screenshot 2024-03-20 at 09 55 03
emersion commented 5 months ago

Alright. That's quite a misuse of the ID command, but oh well.

quzhi1 commented 5 months ago

Thanks for looking into this 🙏

quzhi1 commented 3 months ago

@emersion Can you review this PR? Really appreciate it 🙏 https://github.com/emersion/go-imap/pull/621

emersion commented 3 months ago

Done in #621.