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!

Wrong encoding sending email via SMTP

843834May 27 2008 — edited May 30 2008
I am having a problem sending an e-mail through Gmail SMTP server. All portuguese accented characters are replaced by a question mark. Message source code analisys showed that the default charset is not what I expected to be (UTF8) but ANSI_X3.4-1968. It worked well on a development machine, but didn't on the production environment.

Development machine:
Ubuntu 7.10
System Encoding: UTF8
Default Java Charset:UTF-8

Source code of the message sent by development machine
(...)
MIME-Version: 1.0
Content-Type: text/plain; charset=*UTF-8*
Content-Transfer-Encoding: quoted-printable
(...)

Caro FotoRep=C3=B3rter,
(...)
--- End of message

Production machine
SUSE LINUX 10.0 (i586)
VERSION = 10.0
System Encoding: UTF8
Default Java Charset:UTF-8


Source code of the message sent by production machine
(...)
MIME-Version: 1.0
Content-Type: text/plain; charset=*ANSI_X3.4-1968*
Content-Transfer-Encoding: 7bit
(...)

Caro FotoRep?rter
(...)
--- End of message

The application gets the content from a configuration file:
//(...)
MimeMessage msgtoSend = new MimeMessage(session);
msgtoSend.setText(this.getMessage());
msgtoSend.setSubject(this.getSubject());
//(...)
protected String getSubject() {
subject = ConfigApplicationFacade.getProperties().getProperty("mail.user_notfound.subject");
return subject;
Maybe the problem is there, although the files are exactely the same both on production and development and it worked on development. I wrote a simpler code that gets the content from a string and it works. Any ideas of what could be causing this?

Thanks in advance,
Rodrigo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2008
Added on May 27 2008
6 comments
801 views