@Test public void testMessageFactorySetReplyTo() throws MessagingException { final MimeMessageBuilder builder = new MimeMessageBuilder(null); final String addresses = "testing1@example.com,testing2@example.com"; assertNull(builder.build().getReplyTo()); builder.setReplyTo(null); assertNull(builder.build().getReplyTo()); builder.setReplyTo(addresses); assertArrayEquals(InternetAddress.parse(addresses), builder .build().getReplyTo()); }
assertEquals(1, froms.size()); assertEquals("me@mail.org", ((InternetAddress) froms.get(0)).getAddress()); List<Address> replyTos = Arrays.asList(sentMessage.getReplyTo()); assertEquals("reply@mail.org", ((InternetAddress) replyTos.get(0)).getAddress()); List<Address> tos = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.TO));
assertEquals("'singleobject'", msg.getSubject()); assertEquals("from@domain.com", ((InternetAddress) msg.getFrom()[0]).getAddress()); assertEquals("replyTo@domain.com", ((InternetAddress) msg.getReplyTo()[0]).getAddress());
assertEquals(mySubject, msg.getSubject()); assertEquals("from@domain.com", ((InternetAddress) msg.getFrom()[0]).getAddress()); assertEquals("replyTo@domain.com", ((InternetAddress) msg.getReplyTo()[0]).getAddress());
/** * @return the 'replyTo' address of the email * @throws Exception parsing the mime message failed */ public String getReplyTo() throws Exception { final javax.mail.Address[] addresses = this.mimeMessage.getReplyTo(); if (addresses == null || addresses.length == 0) { return null; } return ((InternetAddress) addresses[0]).getAddress(); }
/** * Get the ReplyTo addresses. */ @Override public Address[] getReplyTo() throws MessagingException { checkExpunged(); if (bodyLoaded) return super.getReplyTo(); loadEnvelope(); /* * The IMAP spec requires that the Reply-To field never be * null, but at least Exchange 2007 fails to fill it in in * some cases. Use the same fallback strategy used by * MimeMessage. */ if (envelope.replyTo == null || envelope.replyTo.length == 0) return getFrom(); return aaclone(envelope.replyTo); }
/** * Get the ReplyTo addresses. */ public Address[] getReplyTo() throws MessagingException { checkExpunged(); if (bodyLoaded) return super.getReplyTo(); loadEnvelope(); /* * The IMAP spec requires that the Reply-To field never be * null, but at least Exchange 2007 fails to fill it in in * some cases. Use the same fallback strategy used by * MimeMessage. */ if (envelope.replyTo == null || envelope.replyTo.length == 0) return getFrom(); return aaclone(envelope.replyTo); }
/** * @return the 'replyTo' address of the email */ public InternetAddress getReplyTo() throws MessagingException { final Address[] addresses = this.mimeMessage.getReplyTo(); if (addresses == null || addresses.length == 0) { return null; } return (InternetAddress) addresses[0]; }
@Test public void testConvertToMimeMessage() throws Exception { EmailWrapper wrapper = getTypicalEmailWrapper(); MimeMessage email = new JavamailService().parseToEmail(wrapper); assertEquals(new InternetAddress(wrapper.getSenderEmail(), wrapper.getSenderName()), email.getFrom()[0]); assertEquals(new InternetAddress(wrapper.getReplyTo()), email.getReplyTo()[0]); assertEquals(new InternetAddress(wrapper.getRecipient()), email.getRecipients(Message.RecipientType.TO)[0]); assertEquals(new InternetAddress(wrapper.getBcc()), email.getRecipients(Message.RecipientType.BCC)[0]); assertEquals(wrapper.getSubject(), email.getSubject()); assertEquals(wrapper.getContent(), email.getContent().toString()); }
reply.setHeader("Subject", subject); Address a[] = getReplyTo(); reply.setRecipients(Message.RecipientType.TO, a); if (replyToAll) {
reply.setHeader("Subject", subject); Address a[] = getReplyTo(); reply.setRecipients(Message.RecipientType.TO, a); if (replyToAll) {
private MailboxAddress findReplyTo(MimeMessage mm) { try { return findSingleAddress(mm.getReplyTo()); } catch (MessagingException ex) { throw new RuntimeException(ex); } }
verifyAddresses(abort.getReplyTo()); } catch (final RuntimeException RE) { setErrorContent(abort, verify, RE);
/** * @see javax.mail.Message#getReplyTo() */ public Address[] getReplyTo() throws MessagingException { return getWrappedMessage().getReplyTo(); }
@SuppressWarnings("WeakerAccess") @Nullable public static InternetAddress parseReplyToAddresses(@Nonnull final MimeMessage mimeMessage) { try { final Address[] addresses = mimeMessage.getReplyTo(); return (addresses == null || addresses.length == 0) ? null : (InternetAddress) addresses[0]; } catch (final MessagingException e) { throw new MimeMessageParseException(MimeMessageParseException.ERROR_PARSING_REPLY_TO_ADDRESSES, e); } }
/** * @return the 'replyTo' address of the email * @throws Exception parsing the mime message failed */ public String getReplyTo() throws Exception { final javax.mail.Address[] addresses = this.mimeMessage.getReplyTo(); if (addresses == null || addresses.length == 0) { return null; } return ((InternetAddress) addresses[0]).getAddress(); }
verifyAddresses(abort.getReplyTo()); } catch (final RuntimeException RE) { setErrorContent(abort, verify, RE);
/** * Does this email belong to our test case (as opposed to other tests that might be running elsewhere?) */ private boolean isOurs(MimeMessage m) { try { Address[] r = m.getReplyTo(); if (r==null) return false; for (Address a : r) { if (a.toString().contains(fingerprint)) return true; } return false; } catch (MessagingException e) { throw new AssertionError(e); } }
private Set<MailAddress> getReplyTosFromMail(Mail mail) { try { InternetAddress[] replyToArray = (InternetAddress[]) mail.getMessage().getReplyTo(); if (replyToArray == null || replyToArray.length == 0) { return getSender(mail); } return getReplyTos(replyToArray); } catch (MessagingException ae) { LOGGER.warn("Unable to parse the \"REPLY_TO\" header in the original message; ignoring."); return ImmutableSet.of(); } }
/** * Get the ReplyTo addresses. */ @Override public Address[] getReplyTo() throws MessagingException { checkExpunged(); if (bodyLoaded) return super.getReplyTo(); loadEnvelope(); /* * The IMAP spec requires that the Reply-To field never be * null, but at least Exchange 2007 fails to fill it in in * some cases. Use the same fallback strategy used by * MimeMessage. */ if (envelope.replyTo == null || envelope.replyTo.length == 0) return getFrom(); return aaclone(envelope.replyTo); }