0% found this document useful (0 votes)
26 views5 pages

Spring Boot Email Notification System

The document contains a Java Spring Boot application that implements an email notification system. It includes classes for handling email requests, sending emails via a service, and configuring email settings. Additionally, it provides a Maven configuration for dependencies and project setup, including database connection properties and JWT settings.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views5 pages

Spring Boot Email Notification System

The document contains a Java Spring Boot application that implements an email notification system. It includes classes for handling email requests, sending emails via a service, and configuring email settings. Additionally, it provides a Maven configuration for dependencies and project setup, including database connection properties and JWT settings.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package [Link].jov_platform.

DTO;

public class EmailRequest {

private String to;


private String subject;
private String body;

public EmailRequest() {}
public EmailRequest(String to,String subject,String body) {
[Link]=to;
[Link]=subject;
[Link]=body;
}

public String getTo() {


return to;
}
public void setTo(String to) {
[Link] = to;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
[Link] = subject;
}
public String getBody() {
return body;
}
public void setBody(String body) {
[Link] = body;
}

------------------------------

package [Link].job_platform.Service;

import [Link];
import [Link];
import [Link];
import [Link];

import [Link].jov_platform.[Link];

@Service
public class EmailService {

@Autowired
private JavaMailSender mailSender;

public String sendEmail(EmailRequest request) {


try {
SimpleMailMessage message = new SimpleMailMessage();

[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link](message);
return "Email sent successful";
} catch (Exception e) {
return "Faild to email";

}
}

----------------------------------

package [Link].job_platform.Controller;

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link].job_platform.[Link];
import [Link].jov_platform.[Link];

@RestController
@RequestMapping("/api/notifications")
public class EmailController {

@Autowired
private EmailService emailService;

@PostMapping("/email")
public ResponseEntity<String>sendEmail(@RequestBody EmailRequest request){
return [Link]([Link](request));

-------------------------------------

package [Link].job_platform.Security;

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
@Configuration
public class MailConfig {

@Bean
public JavaMailSender getJavaMailSender() {

JavaMailSenderImpl sender= new JavaMailSenderImpl();


[Link]("[Link]");
[Link](587);
[Link]("Your-email@[Link]");
[Link]("your-app-password");

Properties props= [Link]();

[Link]("[Link]", "smtp");
[Link]("[Link]", "true");
[Link]("[Link]", "true");
[Link]("[Link]", "true");

return sender;
}

--------------------------------

[Link]=job_platfom

#Database connection
[Link]=jdbc:mysql://localhost:3306/job_portal
[Link]=root
[Link]=Smruti@12345

#JPA
[Link]-auto=update
[Link]-sql=true
[Link]=[Link].MySQL5Dialect

#DEBUG
[Link]=DEBUG
[Link]=TRACE

#Sever
[Link]=7070
#SpringConfig
#[Link]=auth-service

#JWT
[Link]=zidioSecretKey
[Link]=86400000

#Email
[Link]=[Link]
[Link]=587
[Link]=your-email@[Link]
[Link]=your-app-password
[Link]=true
[Link]=true

-----------------------------------

<?xml version="1.0" encoding="UTF-8"?>


<project xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>[Link]</groupId>
<artifactId>job_platfom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>job_platfom</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<[Link]>8</[Link]>
</properties>
<dependencies>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>[Link]</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.15</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>

</project>

You might also like