Skip to content

Commit

Permalink
demoemail added
Browse files Browse the repository at this point in the history
  • Loading branch information
DEBASIS000123 committed Oct 3, 2024
1 parent 68c4321 commit a43b5fd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@
<artifactId>cloudinary-http44</artifactId>
<version>1.36.0</version>
</dependency>


<!--
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-mail -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>


</dependencies>

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/luminex/services/EmailService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.luminex.services;

public interface EmailService {
void sendEmail(String to,String subject,String body);

void sendEmailWithHtml();

void sendEmailWithAttachment();
}
44 changes: 44 additions & 0 deletions src/main/java/com/luminex/services/impl/emailServiceimpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.luminex.services.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import com.luminex.services.EmailService;

@Service
public class emailServiceimpl implements EmailService{

@Autowired
private JavaMailSender emailsender;

@Value("${spring.mail.properties.domain_name}")
private String domain_name;


@Override
public void sendEmailWithHtml() {
// TODO Auto-generated method stub

}

@Override
public void sendEmailWithAttachment() {
// TODO Auto-generated method stub

}

@Override
public void sendEmail(String to, String subject, String body) {

SimpleMailMessage message=new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(body);
message.setFrom(domain_name);
emailsender.send(message);
}

}
11 changes: 11 additions & 0 deletions src/test/java/com/luminex/LuminexApplicationTests.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
package com.luminex;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import com.luminex.services.EmailService;

@SpringBootTest
class LuminexApplicationTests {

@Test
void contextLoads() {
}

@Autowired
private EmailService service;

@Test
void sendEmailTest() {
service.sendEmail("debasismishra000123@gmail.com", "Testing mail", "Working fine");
}

}

0 comments on commit a43b5fd

Please sign in to comment.