简体   繁体   中英

Replacing Illegal Characters in a String

I'm using Javamail to get the FROM address of a message. The problem is I always get the following exception.

javax.mail.internet.AddressException: Local address contains control or whitespace in string ``ÇáÞÑíÉ ÇáÅáßÊÑæäíÉ''

another exception is like

javax.mail.internet.AddressException: Nested group in string ``.:DoWnLoAdiZ:.FiLMs <900000009@google.com>'' at position 12

How can I format the string before showing it and replace all those illegal white spaces,..etc ?

These are in messages you've received, right? They're almost certainly spam, just throw them away. Spammers are notoriously bad about following internet standards.

If you really want to try to read these messages, set the System property "mail.mime.address.strict" to "false", as described in the javadocs for the javax.mail.internet package .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM