List of usage examples for javax.mail MessagingException printStackTrace
public void printStackTrace()
From source file:edu.sjsu.cmpe275.project.service.EmailService.java
@Async public void send(Reservation reservation, String text) { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = null;/*w ww . j av a 2 s . c o m*/ try { helper = new MimeMessageHelper(message, true); helper.setTo(reservation.getEmail()); helper.setReplyTo("cmpe275.mini.hotel@gmail.com"); helper.setFrom("cmpe275.mini.hotel@gmail.com"); helper.setSubject("Your hotel reservation has been confirmed"); helper.setText(text, true); javaMailSender.send(message); } catch (MessagingException e) { e.printStackTrace(); } return; }
From source file:de.fau.amos4.service.ClientServiceImpl.java
@Override public void generateNewPassword(Client client) { String newPassword = RandomStringUtils.random(8, "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"); String newPasswordHash = new BCryptPasswordEncoder().encode(newPassword); try {// w w w . j av a2 s.c o m EmailSender postman = new EmailSender(); String template = "Your new password is: %s. Please change the password as soon as you are logged in."; postman.SendEmail(client.getEmail(), "PersonalFragebogen 2.0", String.format(template, newPassword), null, null); } catch (MessagingException e) { e.printStackTrace(); return; } // Having the return in the catch block, we only save changes when the E-Mail could have successfully been sent client.setPasswordHash(newPasswordHash); clientRepository.save(client); }
From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.MimeMessageRequestEntity.java
public String getContentType() { try {/* w w w. j ava 2 s . co m*/ if (isXOP) { String header = message.getHeader("Content-Type")[0]; return AttachmentUtils.buildMTOMContentType(header, wsdlRequest.getOperation().getAction()); } else { String header = message.getHeader("Content-Type")[0]; int ix = header.indexOf("boundary"); return "multipart/related; type=\"text/xml\"; start=\"" + HttpClientRequestTransport.ROOTPART_SOAPUI_ORG + "\"; " + header.substring(ix); } } catch (MessagingException e) { e.printStackTrace(); } return null; }
From source file:easyproject.service.Mail.java
public void sendMail() { Properties props = new Properties(); props.put("mail.debug", "true"); props.put("mail.smtp.auth", true); props.put("mail.smtp.starttls.enable", true); props.put("mail.smtp.host", servidorSMTP); props.put("mail.smtp.port", puerto); Session session = Session.getInstance(props, null); try {//from w ww . ja va 2s . c o m MimeMessage message = new MimeMessage(session); message.addRecipient(Message.RecipientType.TO, new InternetAddress(destino)); message.setSubject(asunto); message.setSentDate(new Date()); message.setContent(mensaje, "text/html; charset=utf-8"); Transport tr = session.getTransport("smtp"); tr.connect(servidorSMTP, usuario, password); message.saveChanges(); tr.sendMessage(message, message.getAllRecipients()); tr.close(); } catch (MessagingException e) { e.printStackTrace(); } }
From source file:FolderViewer.java
/** * Change the current Folder for the Viewer * * @param what the folder to be viewed *//*w w w . j a v a2 s . co m*/ public void setFolder(Folder what) { try { table.getSelectionModel().clearSelection(); if (SimpleClient.mv != null) SimpleClient.mv.setMessage(null); model.setFolder(what); scrollpane.invalidate(); scrollpane.validate(); } catch (MessagingException me) { me.printStackTrace(); } }
From source file:net.kamhon.ieagle.function.email.SendMail.java
public void send(String to, String cc, String bcc, String from, String subject, String text, String emailType) { // Session session = Session.getInstance(props, null); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(emailServerSetting.getUsername(), emailServerSetting.getPassword()); }//from w w w. j a va2 s . co m }); session.setDebug(emailServerSetting.isDebug()); try { Message msg = new MimeMessage(session); if (StringUtils.isNotBlank(from)) { msg.setFrom(new InternetAddress(from)); } else { msg.setFrom(); } msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false)); if (StringUtils.isNotBlank(cc)) { msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(cc, false)); } if (StringUtils.isNotBlank(bcc)) { msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(bcc, false)); } msg.setSubject(subject); if (Emailq.TYPE_HTML.equalsIgnoreCase(emailType)) { msg.setContent(text, "text/html"); } else { msg.setText(text); } msg.setSentDate(new java.util.Date()); Transport.send(msg); } catch (MessagingException mex) { mex.printStackTrace(); Exception ex = null; if ((ex = mex.getNextException()) != null) { ex.printStackTrace(); } throw new SystemErrorException(mex); } }
From source file:easyproject.utils.SendMail.java
@Override public void run() { Properties props = new Properties(); props.put("mail.debug", "true"); props.put("mail.smtp.auth", true); props.put("mail.smtp.starttls.enable", true); props.put("mail.smtp.host", servidorSMTP); props.put("mail.smtp.port", puerto); Session session = Session.getInstance(props, null); try {/*from ww w . j a v a 2 s. c o m*/ MimeMessage message1 = new MimeMessage(session); message1.addRecipient(Message.RecipientType.TO, new InternetAddress(destino)); message1.setSubject(asunto); message1.setSentDate(new Date()); message1.setContent(mensaje, "text/html; charset=utf-8"); Transport tr = session.getTransport("smtp"); tr.connect(servidorSMTP, usuario, password); message1.saveChanges(); tr.sendMessage(message1, message1.getAllRecipients()); tr.close(); } catch (MessagingException e) { e.printStackTrace(); } }
From source file:com.test.servlet.RegisterController.java
@Override public void setResponse(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); String email = getParam(RequestParam.email.toString()); String password = getParam(RequestParam.password.toString()); String firstName = getParam(RequestParam.first_name.toString()); String lastName = getParam(RequestParam.last_name.toString()); String errorMsg = null;// w ww .j ava2 s . c om if (Utility.isStringEmpty(email)) { writer.print( Utility.generalErrorMessage(ResponseCode.email_not_provided.toString(), "Email is required!")); return; } if (Utility.isStringEmpty(password)) { writer.print(Utility.generalErrorMessage(ResponseCode.password_not_provided.toString(), "Password is required!")); return; } DBUtility dbUtil = new DBUtility(servlet); SessionGenerator generator = SessionGenerator.getInstance(); User user = new User(); user.setEmail(email); user.setFirstName(firstName); user.setLastname(lastName); user.setPassword(password); user.setRegistration_key(generator.nextSessionId()); boolean result = dbUtil.insertUser(user); if (result) { try { MailUtility.sendVerificationEmail(user); } catch (MessagingException ex) { ex.printStackTrace(); } JSONObject jReponse = new JSONObject(); jReponse.put(JSONKey.status.toString(), 0); jReponse.put(JSONKey.message.toString(), "Registration successful. Check your email for instructions on how to verify your account."); writer.print(jReponse.toString()); } else { writer.print(Utility.generalErrorMessage(ResponseCode.email_exists.toString(), "Email address already exists")); } }
From source file:com.rest.EmailSender.java
public void sendVerificationTokenEmail(String emailVerificationToken, String requestBaseUrl) { Locale locale = LocaleContextHolder.getLocale(); String emailVerificationTemplate = ""; switch (locale.toString()) { case "fr": emailVerificationTemplate = "emailVerificationTemplate_fr"; break;//from w w w.j ava2 s.co m default: emailVerificationTemplate = "emailVerificationTemplate_en"; break; } Context ctx = new Context(); ctx.setVariable("emailVerificationToken", emailVerificationToken.toString()); ctx.setVariable("requestBaseUrl", requestBaseUrl.toString()); String emailText = thymeleaf.process(emailVerificationTemplate, ctx); try { sendMessage(bundleMessageReader.getMessage("EmailVerificationEmailHeader"), emailText); } catch (MessagingException e) { e.printStackTrace(); } }
From source file:com.rest.EmailSender.java
public void sendReserPasswordEmail(String resetPasswordToken, String requestBaseUrl) { Locale locale = LocaleContextHolder.getLocale(); String resetPasswordTemplate = ""; switch (locale.toString()) { case "fr": resetPasswordTemplate = "resetPasswordTemplate_fr"; break;/*w w w. j a v a2 s. com*/ default: resetPasswordTemplate = "resetPasswordTemplate_en"; break; } Context ctx = new Context(); ctx.setVariable("resetPasswordToken", resetPasswordToken.toString()); ctx.setVariable("requestBaseUrl", requestBaseUrl.toString()); String emailText = thymeleaf.process(resetPasswordTemplate, ctx); try { sendMessage(bundleMessageReader.getMessage("ResetPasswordEmailHeader"), emailText); } catch (MessagingException e) { e.printStackTrace(); } }