Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postal doesn't correctly support RFC6531 email addresses #51

Open
sfnelson opened this issue Sep 11, 2014 · 3 comments
Open

Postal doesn't correctly support RFC6531 email addresses #51

sfnelson opened this issue Sep 11, 2014 · 3 comments

Comments

@sfnelson
Copy link
Collaborator

RFC6531 email addresses still don't work in postal, #27 only addressed sender names and not email addresses.

(defn make-address
  ([^String addr ^String charset]
     (let [a (try (InternetAddress. addr)
                  (catch Exception _))]
       (if a
         (InternetAddress. (.getAddress a)
                           (.getPersonal a)
                           charset))))
  ([^String addr ^String name-str ^String charset]
     (try (InternetAddress. addr name-str charset)
          (catch Exception _))))

The three argument version of this code is not called by any postal code afaict, and the two argument version returns nil when given non-ascii characters as input, e.g.

(make-address "Tést <[email protected]>" "utf-8") ;; good
=> #<InternetAddress =?utf-8?Q?T=C3=A9st?= <[email protected]>>
(make-address "té[email protected]" "utf-8") ;; bad
=> nil
(make-address "té[email protected]" "Tést" "utf-8") ;; good, but never called
=> #<InternetAddress =?utf-8?Q?T=C3=A9st?= <té[email protected]>>
@drewr
Copy link
Owner

drewr commented Oct 28, 2014

This appears to be a limitation in JavaMail's InternetAddress parser. 1.5.0-b1 behaves the same way.

postal.message> (.getAddress (InternetAddress. "pépé@example.com" "pépé"))
"pépé@example.com"
postal.message> (.getPersonal (InternetAddress. "Pépé <pépé@example.com>"))
AddressException Local address contains control or whitespace  javax.mail.internet.InternetAddress.checkAddress (InternetAddress.java:1213)

Bill Shannon has responded to this issue and thinks RFC6531 support in JavaMail would be premature anyway because not many servers yet support it. That was almost a year ago though.

https://kenai.com/bugzilla/show_bug.cgi?id=6216

@gws
Copy link

gws commented May 9, 2017

We're encountering this issue, but it looks like there's been some recent movement in JavaMail and times have indeed changed - JavaMail 1.6.0 (in RC now, slated for a summer 2017 release) now supports RFC 653[0-2]: https://github.com/javaee/javamail/issues/93#issuecomment-298527783

I'm not familiar enough with postal to submit a PR today (and it may not be workable to depend on a release candidate of JavaMail), but let me know if it would help you out to create a PR for this.

Thank you!

@drewr
Copy link
Owner

drewr commented Nov 16, 2020

These cases work now with Jakarta Mail (née JavaMail) 1.6.5:

postal.message> (.getPersonal (InternetAddress. "Pépé <pépé@example.com>"))
"Pépé"
postal.message> (make-address "té[email protected]" "Tést" "utf-8")
#object[javax.mail.internet.InternetAddress 0x353d19a4 "=?utf-8?Q?T=C3=A9st?= <té[email protected]>"]
postal.message> (make-address "té[email protected]" "utf-8")
#object[javax.mail.internet.InternetAddress 0x1a8ff709 "té[email protected]"]
postal.message> (make-address "Tést <[email protected]>" "utf-8")
#object[javax.mail.internet.InternetAddress 0x3671fd8a "=?utf-8?Q?T=C3=A9st?= <[email protected]>"]

Think we can close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants