示例#1
0
  private void syncUI() {
    boolean started = mailService != null && mailService.isRunning();

    pop3PortLabel.setText(POP3_PORT_LABEL_PREFIX + (started ? mailService.getPop3Port() : ""));
    smtpPortLabel.setText(SMTP_PORT_LABEL_PREFIX + (started ? mailService.getSmtpPort() : ""));
    startButton.setEnabled(!started);
    stopButton.setEnabled(started);
    testMessageButton.setEnabled(started);
  }
示例#2
0
 private void startService() {
   try {
     mailService = new MailService(new FuncTestLoggerImpl());
     mailService.configureAndStartGreenMail(JIRAServerSetup.SMTP_POP3);
     mailService.addUser(DEFAULT_EMAIL_ADDRESS, DEFAULT_USERNAME, DEFAULT_PASSWORD);
     syncUI();
     System.out.println("Mail Service Started.");
   } catch (BindException ex) {
     JOptionPane.showMessageDialog(null, ex.getMessage());
   }
 }
示例#3
0
 private void stopService() {
   if (mailService != null) {
     mailService.stop();
     syncUI();
     System.out.println("Mail Service Stopped.");
   }
 }
示例#4
0
 private void sendTestMessage() {
   if (mailService != null) {
     final String subject = "SwingMail Test Message";
     String body =
         "Hi, I'm a test message from your mail service interface. "
             + "If you're reading me your mail setup is good.";
     mailService.sendTextMessage(DEFAULT_EMAIL_ADDRESS, DEFAULT_EMAIL_ADDRESS, subject, body);
     System.out.println("Test message sent to " + DEFAULT_EMAIL_ADDRESS + ".");
   }
 }