List of usage examples for javax.mail MessagingException printStackTrace
public void printStackTrace()
From source file:FolderTreeNode.java
protected void loadChildren() { // if it is a leaf, just say we have loaded them if (isLeaf()) { hasLoaded = true;/*from ww w . j a v a2 s. c o m*/ return; } try { // Folder[] sub = folder.listSubscribed(); Folder[] sub = folder.list(); // add a FolderTreeNode for each Folder int num = sub.length; for (int i = 0; i < num; i++) { FolderTreeNode node = new FolderTreeNode(sub[i]); // we used insert here, since add() would make // another recursive call to getChildCount(); insert(node, i); } } catch (MessagingException me) { me.printStackTrace(); } }
From source file:StoreTreeNode.java
protected void loadChildren() { try {/*from www .j a v a 2 s. co m*/ // connect to the Store if we need to if (!store.isConnected()) { store.connect(); } // get the default folder, and list the // subscribed folders on it folder = store.getDefaultFolder(); // Folder[] sub = folder.listSubscribed(); Folder[] sub = folder.list(); // add a FolderTreeNode for each Folder int num = sub.length; for (int i = 0; i < num; i++) { FolderTreeNode node = new FolderTreeNode(sub[i]); // we used insert here, since add() would make // another recursive call to getChildCount(); insert(node, i); } } catch (MessagingException me) { me.printStackTrace(); } }
From source file:de.hska.ld.core.service.impl.MailServiceImpl.java
@Override public void sendMail(String fullName, String email, String templateFileName, Map<String, Object> model) { ;/*from w ww . ja v a 2s. c o m*/ if (Boolean.parseBoolean(env.getProperty("email.enabled"))) { Locale locale = LocaleContextHolder.getLocale(); ResourceBundle bundle = ResourceBundle.getBundle("messages", locale); model.put("dear", bundle.getString("email.dear")); model.put("fullName", fullName); model.put("greeting", bundle.getString("email.greeting")); String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "templates/mail/" + templateFileName, "UTF-8", model); Properties properties = getMailProperties(); Session session = Session.getInstance(properties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(MAIL_PROPERTIES.getProperty("email.username"), MAIL_PROPERTIES.getProperty("email.password")); } }); try { MimeMessage message = new MimeMessage(session); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setFrom(MAIL_PROPERTIES.getProperty("email.from.system")); helper.setTo(email); helper.setSubject(model.containsKey("subject") ? (String) model.get("subject") : ""); helper.setText(text, true); Transport.send(message); } catch (MessagingException e) { e.printStackTrace(); } } }
From source file:org.openiam.idm.srvc.msg.service.MailSender.java
public void send(Message msg) { Properties properties = System.getProperties(); properties.setProperty("mail.smtp.host", host); Session session = Session.getDefaultInstance(properties); MimeMessage message = new MimeMessage(session); try {//from w ww . j a va 2 s . c o m message.setFrom(msg.getFrom()); message.addRecipient(javax.mail.Message.RecipientType.TO, msg.getTo()); message.setSubject(msg.getSubject()); message.setText(msg.getBody()); Transport.send(message); log.info("Message successfully sent."); } catch (MessagingException me) { log.error(me); me.printStackTrace(); } }
From source file:cs544.wamp_blog_engine.service.impl.NotificationService.java
public void sendMail(String fromEmail, String toEmail, String emailSubject, String emailBody) { // String fromEmail = emailTemplate.getFrom(); // String[] toEmail = emailTemplate.getTo(); // String[] toEmails = new String[]{toEmail}; // String emailSubject = emailTemplate.getSubject(); // String emailBody = String.format(emailTemplate.getText(), dear, content); MimeMessage mimeMessage = javaMailSender.createMimeMessage(); try {/*w w w .j a va 2s. c o m*/ MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); helper.setFrom(fromEmail); helper.setTo(toEmail); helper.setSubject(emailSubject); helper.setText(emailBody); /* uncomment the following lines for attachment FileSystemResource file = new FileSystemResource("attachment.jpg"); helper.addAttachment(file.getFilename(), file); */ javaMailSender.send(mimeMessage); System.out.println("Mail sent successfully."); } catch (MessagingException e) { e.printStackTrace(); } }
From source file:de.tuttas.servlets.MailSender.java
@Override public void run() { while (true) { if (mails.size() != 0) { try { transmitMail(mails.get(0)); Log.d("Mail erfolgreich versandt an:" + mails.get(0).toString()); mails.remove(0);/*from w w w . j a va2 s .c o m*/ } catch (MessagingException ex) { ex.printStackTrace(); Log.d("Fehler beim Versenden der Mail"); Logger.getLogger(MailSender.class.getName()).log(Level.SEVERE, null, ex); } } try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(MailSender.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.otz.plugins.transport.aws.ses.SpringEmailSender.java
public void send(EventHeader emailHeader, EventContent emailRequestContent) { EmailEventContent emailEventContent = (EmailEventContent) emailRequestContent; try {/*from w ww. j a va2s .com*/ send(emailEventContent.getEmailType(), emailEventContent.getLocale(), emailEventContent.getValues().get(TO), emailEventContent.getValues()); } catch (MessagingException e) { // TODO: re-queue to be sent again e.printStackTrace(); } }
From source file:com.yfiton.notifiers.email.EmailNotifierTest.java
private boolean checkEmailReception(String subject, String host, String username, String password) throws MessagingException { Properties properties = new Properties(); properties.put("mail.store.protocol", "imaps"); Session session = Session.getInstance(properties); Store store = null;/* w w w. j a v a 2s .com*/ try { store = session.getStore("imaps"); store.connect(host, username, password); Folder inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_WRITE); Message[] messages = inbox.getMessages(); for (Message message : messages) { if (message.getSubject().equals(subject)) { message.setFlag(Flags.Flag.DELETED, true); return true; } } inbox.close(true); } finally { try { if (store != null) { store.close(); } } catch (MessagingException e) { e.printStackTrace(); } } return false; }
From source file:com.oak_yoga_studio.service.impl.NotificationServiceImpl.java
public void sendMail(String fromEmail, String toEmail, String emailSubject, String emailBody) { MimeMessage mimeMessage = javaMailSender.createMimeMessage(); try {//from w ww . ja v a2s .c o m MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); helper.setFrom(fromEmail); helper.setTo(toEmail); helper.setSubject(emailSubject); helper.setText(emailBody); /* uncomment the following lines for attachment FileSystemResource file = new FileSystemResource("attachment.jpg"); helper.addAttachment(file.getFilename(), file); */ javaMailSender.send(mimeMessage); System.out.println("Mail sent successfully.");//debugging } catch (MessagingException e) { e.printStackTrace(); } }
From source file:org.runway.users.service.UserPasswordResetServiceImpl.java
private void createAndSendEmail(User user, UserPasswordReset resetRequest) { //SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); MimeMessageHelper msg = new MimeMailMessage(mailSender.createMimeMailMessage()).getMimeMessageHelper(); String title = "Peoplebees password reset request "; try {/*from w w w .ja v a 2 s . c o m*/ msg.setFrom("admin@peoplebees.com"); msg.setTo(user.getEmail()); msg.setSubject(title); String resetLink = UserLinkHelper.createPasswordResetLink(resetRequest); String message = createMessage(title, resetRequest.getHostName(), resetLink, user); msg.setText(message, true); this.mailSender.sendMail(msg); } catch (MessagingException e) { e.printStackTrace(); } }