/** * Address message. * @param msg message, may not be null. * @throws MessagingException thrown if error addressing message. * @since 1.2.14 */ protected void addressMessage(final Message msg) throws MessagingException { if (from != null) { msg.setFrom(getAddress(from)); } else { msg.setFrom(); } //Add ReplyTo addresses if defined. if (replyTo != null && replyTo.length() > 0) { msg.setReplyTo(parseAddress(replyTo)); } if (to != null && to.length() > 0) { msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); } //Add CC receipients if defined. if (cc != null && cc.length() > 0) { msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); } //Add BCC receipients if defined. if (bcc != null && bcc.length() > 0) { msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc)); } }
msg.setReplyTo( address );
User user = TaskModelProvider.getFactory().newUser(); ((InternalOrganizationalEntity) user).setId(header.getReplyTo()); msg.setReplyTo( new InternetAddress[] { new InternetAddress(userInfo.getEmailForEntity(user))}); } else if (mailSession.getProperty("mail.replyto") != null) { msg.setReplyTo( new InternetAddress[] { new InternetAddress(mailSession.getProperty("mail.replyto"))});
address[i] = new InternetAddress( reply_Address_List[i] ); msg.setReplyTo( address );
/** * Sets reply-to address header. * @param msg the target message. */ private void setReplyTo(final Message msg) { final String reply = getSession(msg).getProperty("mail.reply.to"); if (!isEmpty(reply)) { try { final Address[] address = InternetAddress.parse(reply, false); if (address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
/** * Sets reply-to address header. * @param msg the target message. */ private void setReplyTo(final Message msg) { final String reply = getSession(msg).getProperty("mail.reply.to"); if (!isEmpty(reply)) { try { final Address[] address = InternetAddress.parse(reply, false); if (address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
/** * Address message. * @param msg message, may not be null. * @throws MessagingException thrown if error addressing message. * @since 1.2.14 */ protected void addressMessage(final Message msg) throws MessagingException { if (from != null) { msg.setFrom(getAddress(from)); } else { msg.setFrom(); } //Add ReplyTo addresses if defined. if (replyTo != null && replyTo.length() > 0) { msg.setReplyTo(parseAddress(replyTo)); } if (to != null && to.length() > 0) { msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); } //Add CC receipients if defined. if (cc != null && cc.length() > 0) { msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); } //Add BCC receipients if defined. if (bcc != null && bcc.length() > 0) { msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc)); } }
@Override public void setReplyTo(Address[] addresses) throws RuntimeMessagingException { try { delegate.setReplyTo(addresses); } catch (MessagingException e) { throw new RuntimeMessagingException(e); } }
private void setReplyTo(final Message msg, final Properties props) { final String reply = props.getProperty("mail.reply.to"); if (reply != null && reply.length() > 0) { try { final Address[] address = InternetAddress.parse(reply, false); if (address != null && address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
public String sendMail(String from, String to, String replyTo, String subject, String message) { String output=null; Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); try { Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from, "Gmail.com Admin")); msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to, "Mr. User")); msg.setSubject(subject); msg.setText(message); msg.setReplyTo(new InternetAddress[]{new InternetAddress(replyTo)}); Transport.send(msg); } catch (Exception e) { output=e.toString(); } return output; }
/** * Fills the {@link Message} instance with reply-to address. * * @param email The message in which the recipients are defined. * @param message The javax message that needs to be filled with reply-to address. * @throws UnsupportedEncodingException See {@link InternetAddress#InternetAddress(String, String)}. * @throws MessagingException See {@link Message#setReplyTo(Address[])} */ private static void setReplyTo(final Email email, final Message message) throws UnsupportedEncodingException, MessagingException { final Recipient replyToRecipient = email.getReplyToRecipient(); if (replyToRecipient != null) { InternetAddress replyToAddress = new InternetAddress(replyToRecipient.getAddress(), replyToRecipient.getName(), CHARACTER_ENCODING); message.setReplyTo(new Address[] { replyToAddress }); } }
private void sendFailureEmail(Exception e) throws AddressException, MessagingException, UnsupportedEncodingException { Properties props = new Properties(MAIL_PROPERTIES); Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); Message message = new MimeMessage(mailSession); InternetAddress requesterAddress = new InternetAddress(email, requesterName); message.setFrom(new InternetAddress(from, "SHAHED Team")); message.addRecipient(RecipientType.TO, requesterAddress); InternetAddress adminAddress = new InternetAddress("eldawy@cs.umn.edu", "Ahmed Eldawy"); message.addRecipient(RecipientType.BCC, adminAddress); message.setSubject("Confirmation: Your request has failed"); message.setText("Dear "+requesterName+",\n"+ "Unfortunately there was an internal error while processing your request.\n"+ e.getMessage() + "\n" + "Sorry for inconvenience. \n\n Shahed team"); message.setReplyTo(new InternetAddress[] {new InternetAddress(from, "SHAHED Team")}); Transport.send(message, message.getAllRecipients()); LOG.info("Message sent successfully to '"+requesterAddress+"'"); }
/** * Fills the {@link Message} instance with reply-to address. * * @param email The message in which the recipients are defined. * @param message The javax message that needs to be filled with reply-to address. * @throws UnsupportedEncodingException See {@link InternetAddress#InternetAddress(String, String)}. * @throws MessagingException See {@link Message#setReplyTo(Address[])} */ private static void setReplyTo(final Email email, final Message message) throws UnsupportedEncodingException, MessagingException { final Recipient replyToRecipient = email.getReplyToRecipient(); if (replyToRecipient != null) { final InternetAddress replyToAddress = new InternetAddress(replyToRecipient.getAddress(), replyToRecipient.getName(), CHARACTER_ENCODING); message.setReplyTo(new Address[] { replyToAddress }); } }
/** * Sets reply-to address header. * @param msg the target message. */ private void setReplyTo(final Message msg) { final String reply = getSession(msg).getProperty("mail.reply.to"); if (!isEmpty(reply)) { try { final Address[] address = InternetAddress.parse(reply, false); if (address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
/** * Sets reply-to address header. * @param msg the target message. */ private void setReplyTo(final Message msg) { final String reply = getSession(msg).getProperty("mail.reply.to"); if (!isEmpty(reply)) { try { final Address[] address = InternetAddress.parse(reply, false); if (address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
/** * Sets reply-to address header. * @param msg the target message. */ private void setReplyTo(final Message msg) { final String reply = getSession(msg).getProperty("mail.reply.to"); if (!isEmpty(reply)) { try { final Address[] address = InternetAddress.parse(reply, false); if (address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
/** * Sets reply-to address header. * @param msg the target message. */ private void setReplyTo(final Message msg) { final String reply = getSession(msg).getProperty("mail.reply.to"); if (!isEmpty(reply)) { try { final Address[] address = InternetAddress.parse(reply, false); if (address.length > 0) { msg.setReplyTo(address); } } catch (final MessagingException ME) { reportError(ME.getMessage(), ME, ErrorManager.FORMAT_FAILURE); } } }
public void send(String subject, Address from, Address[] replyTo, Address[] to, Address[] cc, Address[] bcc, Multipart multipart) throws Exception { WithContext<Object> action = ctx -> { Message message = new MimeMessage(ctx.session); message.setSentDate(new Date()); message.setFrom(from); message.setSubject(subject); if (replyTo != null) { message.setReplyTo(replyTo); } message.setRecipients(Message.RecipientType.TO, to); if (cc != null) { message.setRecipients(Message.RecipientType.CC, cc); } if (bcc != null) { message.setRecipients(Message.RecipientType.BCC, bcc); } message.setContent(multipart); Transport.send(message); return null; }; performWithContext(action); }
/** * Address message. * @param msg message, may not be null. * @throws MessagingException thrown if error addressing message. * @since 1.2.14 */ protected void addressMessage(final Message msg) throws MessagingException { if (from != null) { msg.setFrom(getAddress(from)); } else { msg.setFrom(); } //Add ReplyTo addresses if defined. if (replyTo != null && replyTo.length() > 0) { msg.setReplyTo(parseAddress(replyTo)); } if (to != null && to.length() > 0) { msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); } //Add CC receipients if defined. if (cc != null && cc.length() > 0) { msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); } //Add BCC receipients if defined. if (bcc != null && bcc.length() > 0) { msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc)); } }
/** * Address message. * @param msg message, may not be null. * @throws MessagingException thrown if error addressing message. * @since 1.2.14 */ protected void addressMessage(final Message msg) throws MessagingException { if (from != null) { msg.setFrom(getAddress(from)); } else { msg.setFrom(); } //Add ReplyTo addresses if defined. if (replyTo != null && replyTo.length() > 0) { msg.setReplyTo(parseAddress(replyTo)); } if (to != null && to.length() > 0) { msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); } //Add CC receipients if defined. if (cc != null && cc.length() > 0) { msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); } //Add BCC receipients if defined. if (bcc != null && bcc.length() > 0) { msg.setRecipients(Message.RecipientType.BCC, parseAddress(bcc)); } }