Skip to content

Commit

Permalink
Properly display base64 encoded email subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilhcem committed May 9, 2014
1 parent 1e73e5d commit 2c09a72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/nilhcem/fakesmtp/FakeSMTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static void main(final String[] args) {
LOGGER.error("Failed to auto-start server in background", e);
}
} else {
System.setProperty("mail.mime.decodetext.strict", "false");
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());

EventQueue.invokeLater(new Runnable() {
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/nilhcem/fakesmtp/gui/tab/MailsListPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.mail.internet.MimeUtility;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
Expand All @@ -22,6 +23,7 @@
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Observable;
import java.util.Observer;
Expand Down Expand Up @@ -189,8 +191,15 @@ public JScrollPane get() {
public void update(Observable o, Object arg) {
if (o instanceof MailSaver) {
EmailModel email = (EmailModel) arg;
model.addRow(new Object[] {dateFormat.format(email.getReceivedDate()),
email.getFrom(), email.getTo(), email.getSubject()});
String subject;
try {
subject = MimeUtility.decodeText(email.getSubject());
} catch (UnsupportedEncodingException e) {
LOGGER.error("", e);
subject = email.getSubject();
}

model.addRow(new Object[] {dateFormat.format(email.getReceivedDate()), email.getFrom(), email.getTo(), subject});
UIModel.INSTANCE.getListMailsMap().put(nbElements++, email.getFilePath());
} else if (o instanceof ClearAllButton) {
// Delete information from the map
Expand Down

0 comments on commit 2c09a72

Please sign in to comment.