Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. <!-- Javax mail-->
  2. <dependency>
  3. <groupId>javax.mail</groupId>
  4. <artifactId>mail</artifactId>
  5. <version>1.4</version>
  6. </dependency>
  7.  
  8. <dependency>
  9. <groupId>javax.activation</groupId>
  10. <artifactId>activation</artifactId>
  11. <version>1.0.2</version>
  12. </dependency>
  13.  
  14. @Controller
  15. public class HomeController extends BaseController {
  16.  
  17. @Autowired
  18. private SimpleOrderManager simpleOrderManager;
  19.  
  20. @RequestMapping(value = "/", method = RequestMethod.GET)
  21. public String home(Model model) {
  22. simpleOrderManager.placeOrder(userDAO.findById(485));
  23.  
  24. // Redirect to the user's dashboard
  25. return "redirect:/users/" + getAuthenticatedUser().getId() + "/dashboard/" + UserHelper.getURLName(getAuthenticatedUser());
  26. }
  27.  
  28. <beans xmlns="http://www.springframework.org/schema/beans"
  29. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  30. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  31. <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
  32. <property name="host" value="mail.comp.state.edu"/>
  33. <property name="port" value="587" />
  34. </bean>
  35.  
  36. <!-- this is a template message that we can pre-load with default state -->
  37. <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage">
  38. <property name="from" value="work@email.org"/>
  39. <property name="subject" value="Your order"/>
  40. </bean>
  41.  
  42. <bean id="reminderManager" class="edu.state.department.peerreview.mvc.utility.SimpleOrderManager">
  43. <property name="mailSender" ref="mailSender"/>
  44. <property name="templateMessage" ref="templateMessage"/>
  45. </bean>
  46. </beans>
  47.  
  48. SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
  49.  
  50. msg.setTo(user.getEmail());
  51. msg.setText("Test Email");
  52. try{
  53. this.mailSender.send(msg);
  54. }
  55. catch (MailException ex) {
  56. // simply log it and go on...
  57. System.err.println(ex.getMessage());
  58. }
  59.  
  60. Properties properties = System.getProperties();
  61. properties.put("mail.smtp.starttls.enable","true");
  62. properties.put("mail.smtp.auth", "false");
  63. properties.put("mail.debug", "true");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement