Exemple #1
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   progressBar.setVisible(true);
   btnNewButton_5.setEnabled(false);
   File dir = new File(inputFilePath);
   mailer =
       new Mailer(
           frame,
           evento,
           dir.getParent(),
           textFieldEmail.getText(),
           textFieldUsername.getText(),
           passwordField.getPassword(),
           textFieldSMTP.getText(),
           textFieldSMTPPort.getText());
   mailer.addPropertyChangeListener(this);
   mailer.execute();
   btnNewButton_5.setEnabled(true);
 }
Exemple #2
0
  public static Result sendMail() {
    Mailer email = new Mailer(play.Play.application());

    Map<String, String[]> formData = request().body().asFormUrlEncoded();
    email.addFrom(utils.HttpUtil.getFirstValueFromQuery(formData, "from"));
    email.setSubject(utils.HttpUtil.getFirstValueFromQuery(formData, "subject"));
    email.addRecipient(utils.HttpUtil.getFirstValueFromQuery(formData, "to"));

    String errorMessage = null;
    boolean sended = false;
    try {
      email.send(utils.HttpUtil.getFirstValueFromQuery(formData, "body"));
      sended = true;
    } catch (EmailException e) {
      errorMessage = e.toString();
      if (e.getCause() != null) {
        errorMessage += "<br/>Caused by: " + e.getCause();
      }
    }

    return writeMail(errorMessage, sended);
  }