package ch.uzh.csg.reimbursement.configuration;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

@Configuration
public class MailConfiguration {

	@Value("${email.host}")
	private String host;

	@Bean
	public JavaMailSender javaMailService() {
		JavaMailSenderImpl sender = new JavaMailSenderImpl();
        sender.setProtocol("smtp");
        sender.setHost("merlin.metanet.ch");
        sender.setPort(25);
        sender.setUsername("reimbursement@davatz.eu");
        sender.setPassword("pnDe978#");

        Properties mailProps = new Properties();
        mailProps.put("mail.smtps.auth", "true");
        mailProps.put("mail.smtp.starttls.enable", "true");
        mailProps.put("mail.smtp.debug", "true");

        sender.setJavaMailProperties(mailProps);
        return sender;
	}

	@Bean
	public SimpleMailMessage simpleMailMessage() {
		SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
		simpleMailMessage.setFrom("davatzc@gmail.com");
		simpleMailMessage.setSubject("[reimbursement] Notification");
		simpleMailMessage.setText("Empty email");
		return simpleMailMessage;
	}
	

//	private Properties getMailProperties() {
//		Properties properties = new Properties();
//		properties.setProperty("mail.transport.protocol", "smtp");//smtps
//		properties.setProperty("mail.smtp.auth", "true");
//		properties.setProperty("mail.smtp.starttls.enable", "true");
//		properties.setProperty("mail.smtps.ssl.trust", "true");
//		properties.setProperty("mail.smtp.debug", "true");
//		return properties;
//	}
}
@@ -561,16 +561,61 @@
 ice() %7B%0A
+%09%09// TODO move properties to properties file%0A
 %09%09JavaMa
@@ -662,24 +662,18 @@
 Impl();%0A
-        
+%09%09
 sender.s
@@ -688,32 +688,26 @@
 ol(%22smtp%22);%0A
-        
+%09%09
 sender.setHo
@@ -727,32 +727,26 @@
 tanet.ch%22);%0A
-        
+%09%09
 sender.setPo
@@ -753,24 +753,18 @@
 rt(25);%0A
-        
+%09%09
 sender.s
@@ -802,24 +802,18 @@
 z.eu%22);%0A
-        
+%09%09
 sender.s
@@ -837,24 +837,18 @@
 78#%22);%0A%0A
-        
+%09%09
 Properti
@@ -880,24 +880,18 @@
 ties();%0A
-        
+%09%09
 mailProp
@@ -920,32 +920,26 @@
 %22, %22true%22);%0A
-        
+%09%09
 mailProps.pu
@@ -978,24 +978,18 @@
 true%22);%0A
-        
+%09%09
 mailProp
@@ -1023,24 +1023,18 @@
 rue%22);%0A%0A
-        
+%09%09
 sender.s
@@ -1070,16 +1070,10 @@
 s);%0A
-        
+%09%09
 retu
@@ -1400,14 +1400,13 @@
 %0A%09%7D%0A
-%09%0A
 %0A
+%09
 //
-%09
+ 
 priv
@@ -1442,20 +1442,20 @@
 ies() %7B%0A
+%09
 //
-%09%09
+ 
 Properti
@@ -1488,20 +1488,20 @@
 ties();%0A
+%09
 //
-%09%09
+ 
 properti
@@ -1558,20 +1558,20 @@
 //smtps%0A
+%09
 //
-%09%09
+ 
 properti
@@ -1604,36 +1604,36 @@
 auth%22, %22true%22);%0A
+%09
 //
-%09%09
+ 
 properties.setPr
@@ -1669,36 +1669,36 @@
 able%22, %22true%22);%0A
+%09
 //
-%09%09
+ 
 properties.setPr
@@ -1737,20 +1737,20 @@
 true%22);%0A
+%09
 //
-%09%09
+ 
 properti
@@ -1796,12 +1796,12 @@
 %22);%0A
+%09
 //
-%09%09
+ 
 retu
@@ -1819,10 +1819,11 @@
 es;%0A
+%09
 //
-%09
+ 
 %7D%0A%7D

add comment/format