Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javamail Sending Failed due to Apostrophe in Sender Address

843834Jun 16 2010 — edited Jun 16 2010
Hi,

I am having difficulties getting an email to send through Javamail when there is an apostrophe in the email. If one of the senders is e'mail@address for example the InternetAddress constructor will add an extra apostrophe to the email address and say Recipient Unknown and then throw an exception.

Code:
message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(toarray));
Exception:
javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
	class com.sun.mail.smtp.SMTPAddressFailedException: 550 <e''mail@address.com>, Recipient unknown
	at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1141)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:536)

Debug Information:
DEBUG SMTP: Invalid Addresses
DEBUG SMTP:   e''mail@address.com
DEBUG SMTP: Sending failed because of invalid destination addresses

Does anyone have any ideas on how I can get around this issue and allow apostrope's and perhaps other characters that should be allowed in email addresses?

Thanks
Alex                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 14 2010
Added on Jun 16 2010
2 comments
1,076 views