Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Javax mail-->
- <dependency>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- <version>1.4</version>
- </dependency>
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- <version>1.0.2</version>
- </dependency>
- @Controller
- public class HomeController extends BaseController {
- @Autowired
- private SimpleOrderManager simpleOrderManager;
- @RequestMapping(value = "/", method = RequestMethod.GET)
- public String home(Model model) {
- simpleOrderManager.placeOrder(userDAO.findById(485));
- // Redirect to the user's dashboard
- return "redirect:/users/" + getAuthenticatedUser().getId() + "/dashboard/" + UserHelper.getURLName(getAuthenticatedUser());
- }
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
- <property name="host" value="mail.comp.state.edu"/>
- <property name="port" value="587" />
- </bean>
- <!-- this is a template message that we can pre-load with default state -->
- <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage">
- <property name="from" value="work@email.org"/>
- <property name="subject" value="Your order"/>
- </bean>
- <bean id="reminderManager" class="edu.state.department.peerreview.mvc.utility.SimpleOrderManager">
- <property name="mailSender" ref="mailSender"/>
- <property name="templateMessage" ref="templateMessage"/>
- </bean>
- </beans>
- SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
- msg.setTo(user.getEmail());
- msg.setText("Test Email");
- try{
- this.mailSender.send(msg);
- }
- catch (MailException ex) {
- // simply log it and go on...
- System.err.println(ex.getMessage());
- }
- Properties properties = System.getProperties();
- properties.put("mail.smtp.starttls.enable","true");
- properties.put("mail.smtp.auth", "false");
- properties.put("mail.debug", "true");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement