public FormValidation doCheckAdminAddress(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { try { setValue(new InternetAddress(text)); } catch (AddressException ex) { throw new IllegalArgumentException("Could not parse mail address: " + ex.getMessage()); } } else { setValue(null); } }
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { try { setValue(new InternetAddress(text)); } catch (AddressException ex) { throw new IllegalArgumentException("Could not parse mail address: " + ex.getMessage()); } } else { setValue(null); } }
GMailClient(MailProperties mailProperties) { String username = mailProperties.getSMTPUsername(); String password = mailProperties.getSMTPPassword(); log.info("Initializing gmail smtp mail transport. Username : {}. SMTP host : {}:{}", username, mailProperties.getSMTPHost(), mailProperties.getSMTPort()); this.session = Session.getInstance(mailProperties, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { this.from = new InternetAddress(username); } catch (AddressException e) { throw new RuntimeException("Error initializing MailWrapper." + e.getMessage()); } }
public FormValidation doCheckAdminAddress(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
public FormValidation doAddressCheck(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
public FormValidation doAddressCheck(@QueryParameter final String value) throws IOException, ServletException { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
private static Optional<InternetAddress> toInternetAddress(String address) { try { return Optional.of(new InternetAddress(address)); } catch (AddressException e) { logger.warn("Cannot send email to address: {} (Cause {})" , address, e.getMessage()); return Optional.empty(); } }
public FormValidation doAddressCheck(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
public FormValidation doAddressCheck(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
public FormValidation doAddressCheck(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
private Address createAddress(String address, TaskListener listener) { try { return new InternetAddress(address); } catch (AddressException e) { e.printStackTrace(listener.error(e.getMessage())); } return null; }
public FormValidation validateFormRecipientList(String recipientList) { // Try and convert the recipient string to a list of InternetAddress. If this fails then the validation fails. try { convertRecipientString(recipientList, new EnvVars(), TO); convertRecipientString(recipientList, new EnvVars(), BCC); convertRecipientString(recipientList, new EnvVars(), CC); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage() + ": \"" + e.getRef() + "\""); } catch(UnsupportedEncodingException e) { return FormValidation.error(e.getMessage()); } }
/** * Test method for {@link MailAddress#MailAddress(javax.mail.internet.InternetAddress)}. */ @Test public void testMailAddressInternetAddress() { try { new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART)); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }
/** * Test method for {@link MailAddress#MailAddress(javax.mail.internet.InternetAddress)}. */ @Test public void testMailAddressInternetAddress() { try { new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART)); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }
/** * Test method for {@link MailAddress#getDomain()}. */ @Test public void testGetDomain() { try { MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS)); assertThat(a.getDomain()).isEqualTo(GOOD_DOMAIN); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }
/** * Test method for {@link MailAddress#getLocalPart()}. */ @Test public void testGetLocalPart() { try { MailAddress a = new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART)); assertThat(a.getLocalPart()).isEqualTo(GOOD_LOCAL_PART); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }
/** * Test method for {@link MailAddress#toString()}. */ @Test public void testToString() { try { MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS)); assertThat(a.toString()).isEqualTo(GOOD_ADDRESS); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }
/** * Test method for {@link MailAddress#getDomain()}. */ @Test public void testGetDomain() { try { MailAddress a = new MailAddress(new InternetAddress(GOOD_ADDRESS)); assertThat(a.getDomain()).isEqualTo(GOOD_DOMAIN); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }
/** * Test method for {@link MailAddress#getLocalPart()}. */ @Test public void testGetLocalPart() { try { MailAddress a = new MailAddress(new InternetAddress(GOOD_QUOTED_LOCAL_PART)); assertThat(a.getLocalPart()).isEqualTo(GOOD_LOCAL_PART); } catch (AddressException e) { System.out.println("AddressException" + e.getMessage()); assertThat(false).describedAs(e.getMessage()).isTrue(); } }