Java Code Examples for org.springframework.mail.javamail.JavaMailSenderImpl#getJavaMailProperties()
The following examples show how to use
org.springframework.mail.javamail.JavaMailSenderImpl#getJavaMailProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaMailSenderFactoryTest.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@Test void testCreateMailSenderWithSpecifiedProperties() { final Properties javaMailProps = new Properties(); javaMailProps.put("mail.debug", "true"); // specify javaMailProps.put("mail.smtp.starttls.enable", "false"); // override when(mailSettings.getJavaMailProperties()).thenReturn(javaMailProps); JavaMailSenderImpl actual = javaMailSenderFactory.createMailSender(mailSettings); assertEquals("host", actual.getHost()); assertEquals(1234, actual.getPort()); assertEquals("username", actual.getUsername()); assertEquals("password", actual.getPassword()); assertEquals("UTF-8", actual.getDefaultEncoding()); final Properties actualProperties = actual.getJavaMailProperties(); assertEquals("false", actualProperties.getProperty("mail.smtp.starttls.enable")); assertEquals("false", actualProperties.getProperty("mail.smtp.quitwait")); assertEquals("true", actualProperties.getProperty("mail.smtp.auth")); assertEquals("true", actualProperties.getProperty("mail.debug")); }
Example 2
Source File: EmailConfiguration.java From tutorials with MIT License | 6 votes |
@Bean public JavaMailSender getJavaMailSender() { JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); mailSender.setHost("smtp.gmail.com"); mailSender.setPort(587); mailSender.setUsername("[email protected]"); mailSender.setPassword("password"); Properties props = mailSender.getJavaMailProperties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "false"); props.put("mail.debug", "true"); return mailSender; }
Example 3
Source File: JavaMailSenderFactoryTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void testCreateMailSenderWithDefaultProperties() { JavaMailSenderImpl actual = javaMailSenderFactory.createMailSender(mailSettings); assertEquals("host", actual.getHost()); assertEquals(1234, actual.getPort()); assertEquals("username", actual.getUsername()); assertEquals("password", actual.getPassword()); assertEquals("UTF-8", actual.getDefaultEncoding()); final Properties actualProperties = actual.getJavaMailProperties(); assertEquals("true", actualProperties.getProperty(MAIL_SMTP_STARTTLS_ENABLE)); assertEquals("false", actualProperties.getProperty(MAIL_SMTP_QUITWAIT)); assertEquals("true", actualProperties.getProperty(MAIL_SMTP_AUTH)); assertEquals("[email protected]", actualProperties.getProperty(MAIL_SMTP_FROM_ADDRESS)); }
Example 4
Source File: JavaMailSenderFactoryTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void testCreateMailSenderWithoutUsernamePassword() { JavaMailSenderImpl actual = javaMailSenderFactory.createMailSender(mailSettings); assertEquals("host", actual.getHost()); assertEquals(1234, actual.getPort()); assertEquals("UTF-8", actual.getDefaultEncoding()); final Properties actualProperties = actual.getJavaMailProperties(); assertEquals("true", actualProperties.getProperty("mail.smtp.starttls.enable")); assertEquals("false", actualProperties.getProperty("mail.smtp.quitwait")); assertEquals("true", actualProperties.getProperty("mail.smtp.auth")); }
Example 5
Source File: EmailAlert.java From redis-manager with Apache License 2.0 | 4 votes |
private JavaMailSender getJavaMailSender(AlertChannel alertChannel) { JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); String smtpHost = alertChannel.getSmtpHost(); String[] hostAndPort = smtpHost.split(SignUtil.COLON); mailSender.setHost(hostAndPort[0]); if (hostAndPort.length > 1) { mailSender.setPort(Integer.parseInt(hostAndPort[0])); } mailSender.setUsername(alertChannel.getEmailUserName()); mailSender.setPassword(alertChannel.getEmailPassword()); Properties props = mailSender.getJavaMailProperties(); props.put("mail.transport.protocol", "smtp"); return mailSender; }