List of usage examples for javax.mail Transport send
public static void send(Message msg) throws MessagingException
From source file:de.helmholtz_muenchen.ibis.utils.abstractNodes.HTExecutorNode.HTExecutorNodeModel.java
private void sendMail(String content) { Properties properties = System.getProperties(); properties.setProperty("mail.smtp.host", emailhost); Session session = Session.getDefaultInstance(properties); try {/* w w w . j av a2 s . c om*/ MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(emailsender)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(email)); message.setSubject(HEADER); message.setText(content); Transport.send(message); } catch (MessagingException mex) { mex.printStackTrace(); } }
From source file:com.blackducksoftware.tools.commonframework.standard.email.CFEmailNotifier.java
/** * This is the actual java mail execution. * * @param notification/* w w w . ja va 2 s .co m*/ */ private void send(EmailTemplate notification) { String from = notification.getFrom(); String to = notification.getTo(); String subject = notification.getSubject(); String style = notification.getStyle(); // body of the email is set and all substitutions of variables are made String body = notification.getBody(); // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", smtpHost); props.put("mail.smtps.port", smtpPort); props.put("mail.smtps.auth", smtpUseAuth ? "true" : "false"); // if (smtpUseAuth) { // // props.setProperty("mail.smtp.auth", smtpUseAuth + ""); // props.setProperty("mail.username", smtpUsername); // props.setProperty("mail.password", smtpPassword); // // } // Get the default Session object. Session session = Session.getDefaultInstance(props); // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); try { // Set the RFC 822 "From" header field using the // value of the InternetAddress.getLocalAddress method. message.setFrom(new InternetAddress(from)); // Add the given addresses to the specified recipient type. message.addRecipients(Message.RecipientType.TO, InternetAddress.parse(to)); // Set the "Subject" header field. message.setSubject(subject); // Sets the given String as this part's content, // with a MIME type of "text/html". message.setContent(style + body, "text/html"); if (smtpUseAuth) { // Send message Transport tr = session.getTransport(smtpProtocol); tr.connect(smtpHost, smtpPort, smtpUsername, smtpPassword); message.saveChanges(); tr.sendMessage(message, message.getAllRecipients()); tr.close(); } else { Transport.send(message); } } catch (AddressException e) { log.error("Email Exception: Cannot connect to email host: " + smtpHost, e); } catch (MessagingException e) { log.error("Email Exception: Cannot send email message", e); } }
From source file:com.iana.boesc.utility.BOESCUtil.java
public static boolean sendEmailWithAttachments(final String emailFrom, final String subject, final InternetAddress[] addressesTo, final String body, final File attachment) { try {/* w w w .j a v a 2 s. c om*/ Session session = Session.getInstance(GlobalVariables.EMAIL_PROPS, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("", ""); } }); MimeMessage message = new MimeMessage(session); // Set From: header field of the header. InternetAddress addressFrom = new InternetAddress(emailFrom); message.setFrom(addressFrom); // Set To: header field of the header. message.addRecipients(Message.RecipientType.TO, addressesTo); // Set Subject: header field message.setSubject(subject); // Create the message part BodyPart messageBodyPart = new javax.mail.internet.MimeBodyPart(); // Fill the message messageBodyPart.setText(body); messageBodyPart.setContent(body, "text/html"); // Create a multi part message Multipart multipart = new javax.mail.internet.MimeMultipart(); // Set text message part multipart.addBodyPart(messageBodyPart); // Part two is attachment messageBodyPart = new javax.mail.internet.MimeBodyPart(); DataSource source = new FileDataSource(attachment); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(attachment.getName()); multipart.addBodyPart(messageBodyPart); // Send the complete message parts message.setContent(multipart); // Send message Transport.send(message); return true; } catch (Exception ex) { ex.getMessage(); return false; } }
From source file:com.sat.common.CustomReport.java
/** * Sendmail.// w w w . ja va 2 s . c o m * * @param msg * the msg * @throws AddressException * the address exception * @throws IOException * Signals that an I/O exception has occurred. */ public static void sendmail(String msg) throws AddressException, IOException { ConfigFileHandlerManager miscConfigFileHandlerManager = new ConfigFileHandlerManager(); miscConfigFileHandlerManager.loadPropertiesBasedonPropertyFileName("com.cisco.lms.lms"); Validate miscValidate = new Validate(); String from = miscValidate.readsystemvariable("MAIL.FROM"); String host = miscValidate.readsystemvariable("MAIL.SMTP.HOST"); String to = miscValidate.readsystemvariable("MAIL.TO"); String subject = miscValidate.readsystemvariable("MAIL.SUBJECT"); String personal = miscValidate.readsystemvariable("MAIL.FROM.PERSONAL"); // Mail to details Properties properties = System.getProperties(); properties.setProperty("mail.smtp.host", host); javax.mail.Session session = javax.mail.Session.getDefaultInstance(properties); // compose the message try { MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from, personal)); message.addRecipients(Message.RecipientType.TO, to); message.setSubject(subject); Multipart mp = new MimeMultipart(); MimeBodyPart htmlPart = new MimeBodyPart(); htmlPart.setContent(msg, "text/html"); mp.addBodyPart(htmlPart); message.setContent(mp); Transport.send(message); System.out.println(msg); System.out.println("message sent successfully...."); } catch (MessagingException mex) { mex.printStackTrace(); } catch (Exception e) { System.out.println("\tException in sending mail to configured mailers list"); } }
From source file:Implement.Service.AdminServiceImpl.java
@Override public boolean sendPackageApprovedEmail(PackageApprovedEmailData emailData) throws MessagingException { String path = System.getProperty("catalina.base"); MimeBodyPart logo = new MimeBodyPart(); // attach the file to the message DataSource source = new FileDataSource(new File(path + "/webapps/Images/Email/logoIcon.png")); logo.setDataHandler(new DataHandler(source)); logo.setFileName("logoIcon.png"); logo.setDisposition(MimeBodyPart.INLINE); logo.setHeader("Content-ID", "<logo_Icon>"); // cid:image_cid MimeBodyPart facebook = new MimeBodyPart(); // attach the file to the message source = new FileDataSource(new File(path + "/webapps/Images/Email/facebookIcon.png")); facebook.setDataHandler(new DataHandler(source)); facebook.setFileName("facebookIcon.png"); facebook.setDisposition(MimeBodyPart.INLINE); facebook.setHeader("Content-ID", "<fb_Icon>"); // cid:image_cid MimeBodyPart twitter = new MimeBodyPart(); // attach the file to the message source = new FileDataSource(new File(path + "/webapps/Images/Email/twitterIcon.png")); twitter.setDataHandler(new DataHandler(source)); twitter.setFileName("twitterIcon.png"); twitter.setDisposition(MimeBodyPart.INLINE); twitter.setHeader("Content-ID", "<twitter_Icon>"); // cid:image_cid MimeBodyPart insta = new MimeBodyPart(); // attach the file to the message source = new FileDataSource(new File(path + "/webapps/Images/Email/instaIcon.png")); insta.setDataHandler(new DataHandler(source)); insta.setFileName("instaIcon.png"); insta.setDisposition(MimeBodyPart.INLINE); insta.setHeader("Content-ID", "<insta_Icon>"); // cid:image_cid MimeBodyPart youtube = new MimeBodyPart(); // attach the file to the message source = new FileDataSource(new File(path + "/webapps/Images/Email/youtubeIcon.png")); youtube.setDataHandler(new DataHandler(source)); youtube.setFileName("youtubeIcon.png"); youtube.setDisposition(MimeBodyPart.INLINE); youtube.setHeader("Content-ID", "<yt_Icon>"); // cid:image_cid MimeBodyPart pinterest = new MimeBodyPart(); // attach the file to the message source = new FileDataSource(new File(path + "/webapps/Images/Email/pinterestIcon.png")); pinterest.setDataHandler(new DataHandler(source)); pinterest.setFileName("pinterestIcon.png"); pinterest.setDisposition(MimeBodyPart.INLINE); pinterest.setHeader("Content-ID", "<pin_Icon>"); // cid:image_cid String content = "<div style=' width: 507px;background-color: #f2f2f4;'>" + " <div style='padding: 30px 0;text-align: center; color: #fff; background-color: #ff514e;font-size: 30px;font-weight: bold;'>" + " <img style=' text-align:center;' width=57 height=57 src='cid:logo_Icon'/>" + " <p style='margin:25px 0px 0px 0px;'> Package Approved! </p>" + " </div>" + " <div style=' padding: 50px;margin-bottom: 20px;'>" + " <div id='email-form'>" + " <div style='margin-bottom: 20px'>" + " Hi " + emailData.getLastName() + " ,<br/>" + " Your package " + emailData.getLastestPackageName() + " has been approved" + " </div>" + " <div style='margin-bottom: 20px'>" + " Thanks,<br/>" + " Youtripper team\n" + " </div>" + " </div>" + " <div style='border-top: solid 1px #c4c5cc;text-align:center;'>" + " <p style='text-align: center; color: #3b3e53;margin-top: 10px;margin-bottom: 0px;font-size: 10px;'>Sent from Youtripper.com</p>" + " <div>" + " <a href='https://www.facebook.com/youtrippers/'><img style='margin:10px;' src='cid:fb_Icon' alt=''/></a>" + " <a href='https://twitter.com/youtrippers'><img style='margin:10px;' src='cid:twitter_Icon' alt=''/></a>" + " <a href='https://www.instagram.com/youtrippers/'><img style='margin:10px;' src='cid:insta_Icon' alt=''/></a>" + " <a href='https://www.youtube.com/channel/UCtd4xd_SSjRR9Egug7tXIWA'><img style='margin:10px;' src='cid:yt_Icon' alt=''/></a>" + " <a href='https://www.pinterest.com/youtrippers/'><img style='margin:10px;' src='cid:pin_Icon' alt=''/></a>" + " </div>" + " <p>Youtripper Ltd., 56 Soi Seri Villa, Srinakarin Rd., Nongbon," + " <br>Pravet, Bangkok, Thailand 10250</p>" + " </div>" + " </div>" + "</div>"; MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(content, "US-ASCII", "html"); Multipart mp = new MimeMultipart("related"); mp.addBodyPart(mbp1);//from www .j a v a2s .com mp.addBodyPart(logo); mp.addBodyPart(facebook); mp.addBodyPart(twitter); mp.addBodyPart(insta); mp.addBodyPart(youtube); mp.addBodyPart(pinterest); final String username = "noreply@youtripper.com"; final String password = "Tripper190515"; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "mail.youtripper.com"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); Message message = new MimeMessage(session); message.setFrom(new InternetAddress("noreply@youtripper.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailData.getEmail())); message.setSubject("Package Approved!"); message.setContent(mp); message.saveChanges(); Transport.send(message); return true; }
From source file:jp.mamesoft.mailsocketchat.Mail.java
public static void Send(String to, int mode) { //mode 0 = ?, 1 = ?, 2 = ?, 3 = ??, 4 = , 5 = System.out.println("???"); String from = Mailsocketchat.mail_user; String host = "smtp.gmail.com"; String port = "465"; String text = ""; String subject = ""; if (mode == 0) { text = logprint(text);//from w w w .ja va 2s . c o m subject = " - MailSocketChat"; if (Mailsocketchat.newver) { text = text + "\n\n??????????\n"; } } if (mode == 1) { if (Mailsocketchat.subjectname) { subject = Mailsocketchat.logs.get(0).get("name"); } else { subject = "?? - MailSocketChat"; } text = logprint(text); } if (mode == 8) { text = logprint(text); subject = "?? - MailSocketChat"; } if (mode == 2) { if (!Mailsocketchat.push) { subject = "????? - MailSocketChat"; text = "???????????????????\n\n??????\n"; text = logprint(text); } else { subject = "??? - MailSocketChat"; text = "?????????????????\n(???????????)\n\n"; } if (Mailsocketchat.newver) { text = text + "\n\n??????????\n"; } } if (mode == 3) { if (!Mailsocketchat.push && !Mailsocketchat.repeat) { subject = "???? - MailSocketChat"; text = "????\n\n??????\n"; text = logprint(text); } else { subject = "?????? - MailSocketChat"; text = "?????????????????\n\n"; if (Mailsocketchat.repeat) { text = text + "??????\n"; text = logprint(text); } } if (Mailsocketchat.newver) { text = text + "\n\n??????????\n"; } } if (mode == 7) { if (!Mailsocketchat.repeat) { subject = "????? - MailSocketChat"; text = "?????30????????????\n\n"; if (!Mailsocketchat.push) { text = text + "??????\n"; text = logprint(text); } } else { subject = "??? - MailSocketChat"; text = "???\n\n"; } if (Mailsocketchat.newver) { text = text + "\n\n??????????\n"; } } if (mode == 4) { subject = " - MailSocketChat"; int userint = Mailsocketchat.users.size(); int romint = Mailsocketchat.roms.size(); text = ": " + userint + " ROM: " + romint + "\n\n\n"; for (Integer id : Mailsocketchat.users.keySet()) { HashMap<String, String> data = Mailsocketchat.users.get(id); text = text + data.get("name") + "\n"; text = text + " (" + data.get("ip") + ")\n"; } text = text + "\n\nROM\n"; for (Integer id : Mailsocketchat.roms.keySet()) { HashMap<String, String> data = Mailsocketchat.roms.get(id); text = text + data.get("ip") + "\n"; } if (Mailsocketchat.newver) { text = text + "\n\n??????????\n"; } } if (mode == 5) { subject = " - MailSocketChat"; if (Mailsocketchat.push) { text = "??: \n\n"; } else if (Mailsocketchat.repeat) { text = "??: \n\n"; } else { text = "??: ?\n\n"; } text = text + "?\n"; text = text + "?(fetch): ?????\n"; text = text + "(push): ????\n"; text = text + "(repeat): ????\n"; text = text + "(list): ???\n"; text = text + "#: ?????\n"; text = text + "#hoge: ??hoge????\n"; text = text + "(help): ?????\n\n"; text = text + "\nMailSocketChat Ver." + Mailsocketchat.version + "\n"; if (Mailsocketchat.newver) { text = text + "??????????\n"; } } if (mode == 6) { subject = "????????? - MailSocketChat"; text = text + "MailSocketChat??????????????????\n"; } // create some properties and get the default Session Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.transport.protocol", "smtps"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); props.put("mail.smtp.host", host); props.put("mail.smtp.port", port); Session sendsession = Session.getInstance(props, new PlainAuthenticator(Mailsocketchat.mail_user, Mailsocketchat.mail_pass)); try { // create a message MimeMessage msg = new MimeMessage(sendsession); msg.setFrom(new InternetAddress(from)); InternetAddress[] sendaddress = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, sendaddress); msg.setSubject(subject); msg.setSentDate(new Date()); // If the desired charset is known, you can use // setText(text, charset) msg.setText(text); Transport.send(msg); System.out.println("?????"); } catch (MessagingException mex) { System.out.println("??????"); } }
From source file:io.starter.datamodel.Sys.java
/** * /*from w ww. j av a2 s . c o m*/ * @param params * @throws Exception * * */ public static void sendEmail(String url, final User from, String toEmail, Map params, SqlSession session, CountDownLatch latch) throws Exception { final CountDownLatch ltc = latch; if (from == null) { throw new ServletException("Sys.sendEmail cannot have a null FROM User."); } String fromEmail = from.getEmail(); final String fro = fromEmail; final String to = toEmail; final Map p = params; final String u = url; final SqlSession sr = session; // TODO: check message sender/recipient validity if (!checkEmailValidity(fromEmail)) { throw new RuntimeException( fromEmail + " is not a valid email address. SENDING MESSAGE TO " + toEmail + " FAILED"); } // TODO: check mail server if it's a valid message if (!checkEmailValidity(toEmail)) { throw new RuntimeException( toEmail + " is not a valid email address. SENDING MESSAGE TO " + toEmail + " FAILED"); } // message.setSubject("Testing Email From Starter.io"); // Send the actual HTML message, as big as you like // fetch the content final String content = getText(u); new Thread(new Runnable() { @Override public void run() { // Sender's email ID needs to be mentioned // String sendAccount = "$EMAIL_USER_NAME$"; // final String username = "$EMAIL_USER_NAME$", password = // "hum0rm3"; // Assuming you are sending email from localhost // String host = "gator3083.hostgator.com"; String sendAccount = "$EMAIL_USER_NAME$"; final String username = "$EMAIL_USER_NAME$", password = "$EMAIL_USER_PASS$"; // Assuming you are sending email from localhost String host = SystemConstants.EMAIL_SERVER; // Get system properties Properties props = System.getProperties(); // Setup mail server props.setProperty("mail.smtp.host", host); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.port", "587"); // Get the default Session object. Session session = Session.getInstance(props, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(sendAccount)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(sendAccount)); // Set Subject: header field Object o = p.get("MESSAGE_SUBJECT"); message.setSubject(o.toString()); String ctx = new String(content.toString()); // TODO: String Rep on the params ctx = stringRep(ctx, p); message.setContent(ctx, "text/html; charset=utf-8"); // message.setContent(new Multipart()); // Send message Transport.send(message); Logger.log("Sending message to:" + to + " SUCCESS"); } catch (MessagingException mex) { // mex.printStackTrace(); Logger.log("Sending message to:" + to + " FAILED"); Logger.error("Sys.sendEmail() failed to send message. Messaging Exception: " + mex.toString()); } // log the data Syslog logEntry = new Syslog(); logEntry.setDescription("OK [ email sent from: " + fro + " to: " + to + "]"); logEntry.setUserId(from.getId()); logEntry.setEventType(SystemConstants.LOG_EVENT_TYPE_SEND_EMAIL); logEntry.setSourceId(from.getId()); // unknown logEntry.setSourceType(SystemConstants.TARGET_TYPE_USER); logEntry.setTimestamp(new java.util.Date(System.currentTimeMillis())); SqlSessionFactory sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory(); SqlSession sesh = sqlSessionFactory.openSession(true); sesh.insert("io.starter.dao.SyslogMapper.insert", logEntry); sesh.commit(); if (ltc != null) ltc.countDown(); // release the latch } }).start(); }
From source file:Model.DAO.java
public void sendEmail(int id, String status) { SimpleDateFormat formatDateTime = new SimpleDateFormat("dd/MM/yyyy-HH:mm"); Properties props = new Properties(); /** Parmetros de conexo com servidor Gmail */ props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("seuemail@gmail.com", "suasenha"); }//ww w .ja v a 2s .c o m }); /** Ativa Debug para sesso */ try { PreparedStatement stmt = this.conn .prepareStatement("SELECT * FROM Reservation re WHERE idReservas = ?"); stmt.setInt(1, id); ResultSet rs = stmt.executeQuery(); rs.next(); String date = formatDateTime.format(rs.getTimestamp("dateTime")).split("-")[0]; String time = formatDateTime.format(rs.getTimestamp("dateTime")).split("-")[1]; Message message = new MimeMessage(session); message.setFrom(new InternetAddress("pck1993@gmail.com")); //Remetente Address[] toUser = InternetAddress //Destinatrio(s) .parse(rs.getString("email")); message.setRecipients(Message.RecipientType.TO, toUser); message.setSubject("Status Reserva");//Assunto message.setText("Email de alterao do status da resreva no dia " + date + " s " + time + " horas para " + status); /**Mtodo para enviar a mensagem criada*/ Transport.send(message); } catch (MessagingException e) { throw new RuntimeException(e); } catch (SQLException ex) { Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.silverpeas.mailinglist.service.job.TestMessageChecker.java
@Test public void testProcessEmailTextWithAttachment() throws MessagingException, IOException { MessageListener mockListener1 = mock(MessageListener.class); when(mockListener1.getComponentId()).thenReturn("componentId"); when(mockListener1.checkSender("bart.simpson@silverpeas.com")).thenReturn(Boolean.TRUE); MessageListener mockListener2 = mock(MessageListener.class); messageChecker.addMessageListener(mockListener1); messageChecker.addMessageListener(mockListener2); Map<String, MessageListener> listenersByEmail = new HashMap<String, MessageListener>(2); listenersByEmail.put("thesimpsons@silverpeas.com", mockListener1); listenersByEmail.put("theflanders@silverpeas.com", mockListener2); MimeMessage mail = new MimeMessage(messageChecker.getMailSession()); InternetAddress bart = new InternetAddress("bart.simpson@silverpeas.com"); InternetAddress theSimpsons = new InternetAddress("thesimpsons@silverpeas.com"); mail.addFrom(new InternetAddress[] { bart }); mail.addRecipient(RecipientType.TO, theSimpsons); mail.setSubject("Plain text Email test with attachment"); MimeBodyPart attachment = new MimeBodyPart(TestMessageChecker.class.getResourceAsStream("lemonde.html")); attachment.setDisposition(Part.INLINE); attachment.setFileName("lemonde.html"); MimeBodyPart body = new MimeBodyPart(); body.setText(textEmailContent);/*from www .j a v a 2 s .com*/ Multipart multiPart = new MimeMultipart(); multiPart.addBodyPart(body); multiPart.addBodyPart(attachment); mail.setContent(multiPart); mail.setSentDate(new Date()); Date sentDate = new Date(mail.getSentDate().getTime()); Transport.send(mail); Map<MessageListener, MessageEvent> events = new HashMap<MessageListener, MessageEvent>(); messageChecker.processEmail(mail, events, listenersByEmail); assertNotNull(events); assertEquals(1, events.size()); assertNull(events.get(mockListener2)); MessageEvent event = events.get(mockListener1); assertNotNull(event); assertNotNull(event.getMessages()); assertEquals(1, event.getMessages().size()); Message message = event.getMessages().get(0); assertEquals("bart.simpson@silverpeas.com", message.getSender()); assertEquals("Plain text Email test with attachment", message.getTitle()); assertEquals(textEmailContent, message.getBody()); assertEquals(textEmailContent.substring(0, 200), message.getSummary()); assertEquals(ATT_SIZE, message.getAttachmentsSize()); assertEquals(1, message.getAttachments().size()); String path = MessageFormat.format(attachmentPath, messageChecker.getMailProcessor().replaceSpecialChars(message.getMessageId())); Attachment attached = message.getAttachments().iterator().next(); assertEquals(path, attached.getPath()); assertEquals("lemonde.html", attached.getFileName()); assertEquals("componentId", message.getComponentId()); assertEquals(sentDate.getTime(), message.getSentDate().getTime()); assertEquals("text/plain", message.getContentType()); org.jvnet.mock_javamail.Mailbox.clearAll(); verify(mockListener1, atLeastOnce()).checkSender("bart.simpson@silverpeas.com"); verify(mockListener1, times(2)).getComponentId(); }