Merge branch 'MailSystem' into main
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -19,6 +19,10 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
@@ -56,6 +60,11 @@
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>5.2.9.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.github.cato447.AbizeitungVotingSystem.repositories.CategoryRepository
|
||||
import com.github.cato447.AbizeitungVotingSystem.repositories.VoterRepository;
|
||||
import com.github.cato447.AbizeitungVotingSystem.table.TableAction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -39,6 +41,9 @@ public class VotingController {
|
||||
@Autowired
|
||||
CategoryRepository categoryRepository;
|
||||
|
||||
@Autowired
|
||||
JavaMailSender emailSender;
|
||||
|
||||
@RequestMapping("/")
|
||||
public String WelcomeSite() {
|
||||
|
||||
@@ -66,6 +71,15 @@ public class VotingController {
|
||||
|
||||
return "start.html";
|
||||
}
|
||||
|
||||
public void sendSimpleMessage(
|
||||
String to, String subject, String text) {
|
||||
SimpleMailMessage message = new SimpleMailMessage();
|
||||
message.setTo(to);
|
||||
message.setSubject(subject);
|
||||
message.setText(text);
|
||||
emailSender.send(message);
|
||||
}
|
||||
|
||||
@RequestMapping("/vote")
|
||||
public String VerifyName(@RequestParam String name, Model model) {
|
||||
@@ -80,6 +94,7 @@ public class VotingController {
|
||||
List<Category> categories = categoryRepository.findAll();
|
||||
model.addAttribute("candidates", candidates);
|
||||
model.addAttribute("categories", categories);
|
||||
sendSimpleMessage(name,"test", "test");
|
||||
LOGGER.info(name + " is voting now");
|
||||
return "voting.html";
|
||||
}
|
||||
|
||||
@@ -6,3 +6,15 @@ spring.jpa.hibernate.ddl-auto=update
|
||||
|
||||
# Tomcat
|
||||
server.port = 8000
|
||||
|
||||
######Email Properties ######
|
||||
spring.mail.host=smtp.gmail.com
|
||||
spring.mail.port=587
|
||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
spring.mail.username=adolfinumvoting@gmail.com
|
||||
spring.mail.password=Voting2021
|
||||
spring.mail.properties.mail.smtp.starttls.required=true
|
||||
spring.mail.properties.mail.smtp.auth=true
|
||||
spring.mail.properties.mail.smtp.connectiontimeout=5000
|
||||
spring.mail.properties.mail.smtp.timeout=5000
|
||||
spring.mail.properties.mail.smtp.writetimeout=5000
|
||||
Reference in New Issue
Block a user