Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mail.demo;
- import com.mail.demo.service.MailService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.CommandLineRunner;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- @SpringBootApplication
- public class DemoApplication implements CommandLineRunner {
- @Autowired
- MailService mailService;
- public static void main(String[] args) {
- SpringApplication.run(DemoApplication.class, args);
- }
- @Override
- public void run(String... args) throws Exception {
- try {
- mailService.sendMail("poolsaliya@gmail.com", "poolsaliya@gmail.com", "Mail from SpringBoot", "hello");
- System.out.println("done");
- }
- catch (Exception e) {
- System.out.println(e.getMessage());
- }
- }
- }
Add Comment
Please, Sign In to add comment