示例#1
0
 public static String toString(Message message) {
   StringBuilder sb = new StringBuilder();
   try {
     sb.append(getFromFormated(message));
     sb.append(":");
     sb.append(message.getSubject());
   } catch (Throwable ex) {
     message.toString();
   }
   return sb.toString();
 }
示例#2
0
  private static void replayError(Message msg, String subject, String body, String string)
      throws SQLException, MessagingException, IOException {
    log("Sending error to " + string);
    log("Message:\n" + msg.toString());

    String connStr = "jdbc:mysql://" + properties.getProperty("db");
    // System.out.println("Database: " + connStr);
    Connection connection =
        DriverManager.getConnection(
            connStr, properties.getProperty("user"), properties.getProperty("pass"));

    String usermail = null;
    Address[] from = msg.getFrom();
    for (int i = 0; i < from.length; i++) {
      if (from[i] instanceof InternetAddress) {
        usermail = ((InternetAddress) from[i]).getAddress();
      }
    }
    if (usermail == null) {
      return;
    }

    // verification email
    String email = "From: " + properties.getProperty("message_from") + "\n";
    email += "To: " + usermail + "\n";
    email += "Subject: Submission error\n";
    email += "Your submission encountered a problem:\n" + string + "\n\n";
    // email += "Post subject: " + subject + "\n\n";
    // email += "Post content: \n" + body + "\n";

    // System.out.println("Message is:");
    // System.out.println(email);

    send(email, usermail);

    System.exit(0);
  }