Hi everyone!
I have a serious problem concerning message encoding on different machines. On my development machine (running WinXP) I can send email messages perfectly with this code:
MimeMessagePreparator pwMessagePreparator = new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws MessagingException {
mimeMessage.setHeader("Content-Transfer-Encoding", "8bit");
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, "ISO-8859-1");
message.setSubject("Engineering-Days - Neues Passwort");
message.setTo(address);
String messageText = "Hallo!\n\n" +
"Dein Passwort wurde neu gesetzt. Es lautet jetzt: " + newPw + "\n" +
"Logge Dich damit bitte auf der Homepage ein und �ndere unter \"Mein Konto\" das Passwort.\n\n" +
try {
message.setText(new String(messageText.getBytes("ISO-8859-1")));
} catch (UnsupportedEncodingException ex) {
logger.error(ex);
}
}};
try {
mailSender.send(pwMessagePreparator);
} catch (MailException e) {
logger.warn("Senden der Mail f�r User " + address + " nicht erfolgreich: " + e.getMessage());
}
The text is German, never mind its meaning, what counts is that there are umlauts in it. The message is displayed correctly, the header is also correct:
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
I set mail.smtp.allow8bitmime to true.
As soon as I deploy the code on my production machine, the header looks like this:
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
No matter what I do, it is always set to 7bit. Therefore, the umlauts are not transmitted correctly. I also tried lots of different things, including setting the charset to different values, using MimeUtility and so on. Nothing worked.
Any suggestions are highly appreciated.
Best regards,
Jan-Philipp Stegh�fer