| Line 21... |
Line 21... |
| 21 |
import org.apache.velocity.app.VelocityEngine;
|
21 |
import org.apache.velocity.app.VelocityEngine;
|
| 22 |
import org.apache.velocity.exception.VelocityException;
|
22 |
import org.apache.velocity.exception.VelocityException;
|
| 23 |
import org.springframework.context.annotation.Bean;
|
23 |
import org.springframework.context.annotation.Bean;
|
| 24 |
import org.springframework.context.annotation.ComponentScan;
|
24 |
import org.springframework.context.annotation.ComponentScan;
|
| 25 |
import org.springframework.context.annotation.Configuration;
|
25 |
import org.springframework.context.annotation.Configuration;
|
| - |
|
26 |
import org.springframework.context.annotation.Primary;
|
| 26 |
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
27 |
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
| 27 |
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
28 |
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
| 28 |
import org.springframework.core.io.ClassPathResource;
|
29 |
import org.springframework.core.io.ClassPathResource;
|
| 29 |
import org.springframework.core.io.Resource;
|
30 |
import org.springframework.core.io.Resource;
|
| 30 |
import org.springframework.mail.javamail.JavaMailSender;
|
31 |
import org.springframework.mail.javamail.JavaMailSender;
|
| Line 204... |
Line 205... |
| 204 |
}
|
205 |
}
|
| 205 |
LOGGER.info("Profile is [{}]", properties.get("profile"));
|
206 |
LOGGER.info("Profile is [{}]", properties.get("profile"));
|
| 206 |
return (String) properties.get("profile");
|
207 |
return (String) properties.get("profile");
|
| 207 |
}
|
208 |
}
|
| 208 |
|
209 |
|
| 209 |
@Bean(name = "mailSender")
|
- |
|
| 210 |
public JavaMailSender getSendgridMailSender() {
|
- |
|
| 211 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
- |
|
| 212 |
|
- |
|
| 213 |
// Using gmail
|
- |
|
| 214 |
mailSender.setHost("smtp.sendgrid.net");
|
- |
|
| 215 |
mailSender.setPort(587);
|
- |
|
| 216 |
mailSender.setUsername("apikey");
|
- |
|
| 217 |
mailSender.setPassword("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");
|
- |
|
| 218 |
|
- |
|
| 219 |
Properties javaMailProperties = new Properties();
|
- |
|
| 220 |
javaMailProperties.put("mail.smtp.starttls.enable", "false");
|
- |
|
| 221 |
javaMailProperties.put("mail.smtp.auth", "true");
|
- |
|
| 222 |
javaMailProperties.put("mail.transport.protocol", "smtp");
|
- |
|
| 223 |
javaMailProperties.put("mail.debug", "true");// Prints out everything on
|
- |
|
| 224 |
// screen
|
- |
|
| 225 |
javaMailProperties.put("mail.smtp.connectiontimeout", "10000");
|
- |
|
| 226 |
javaMailProperties.put("mail.smtp.timeout", "10000");
|
- |
|
| 227 |
javaMailProperties.put("mail.smtp.writetimeout", "10000");
|
- |
|
| 228 |
|
- |
|
| 229 |
mailSender.setJavaMailProperties(javaMailProperties);
|
- |
|
| 230 |
return mailSender;
|
- |
|
| 231 |
}
|
- |
|
| 232 |
|
- |
|
| 233 |
@Bean(name = "gmailRelaySender")
|
210 |
@Bean(name = "gmailRelaySender")
|
| 234 |
public JavaMailSender getGmailRelaySender() {
|
211 |
public JavaMailSender getGmailRelaySender() {
|
| 235 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
212 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
| 236 |
mailSender.setHost("smtp-relay.gmail.com");
|
213 |
mailSender.setHost("smtp-relay.gmail.com");
|
| 237 |
mailSender.setPort(587);
|
214 |
mailSender.setPort(587);
|
| Line 249... |
Line 226... |
| 249 |
|
226 |
|
| 250 |
return mailSender;
|
227 |
return mailSender;
|
| 251 |
}
|
228 |
}
|
| 252 |
|
229 |
|
| 253 |
|
230 |
|
| - |
|
231 |
/**
|
| - |
|
232 |
* The default sender. Authenticates as sdtech@smartdukaan.com and rewrites every
|
| - |
|
233 |
* From to that identity — Workspace binds an authenticated session to one address
|
| - |
|
234 |
* and rejects any other. Also answers to "mailSender" so unqualified
|
| - |
|
235 |
* JavaMailSender injections resolve here.
|
| - |
|
236 |
*/
|
| - |
|
237 |
@Bean(name = {"googleMailSender", "mailSender"})
|
| 254 |
@Bean
|
238 |
@Primary
|
| 255 |
public JavaMailSender googleMailSender() {
|
239 |
public JavaMailSender googleMailSender() {
|
| 256 |
JavaMailSenderImpl mailSender = new AuthenticatedIdentityMailSender();
|
240 |
JavaMailSenderImpl mailSender = new AuthenticatedIdentityMailSender();
|
| 257 |
mailSender.setHost("smtp.gmail.com");
|
241 |
mailSender.setHost("smtp.gmail.com");
|
| 258 |
mailSender.setPort(465);
|
242 |
mailSender.setPort(465);
|
| 259 |
mailSender.setUsername("sdtech@smartdukaan.com");
|
243 |
mailSender.setUsername("sdtech@smartdukaan.com");
|