Отправить электронную почту с SpringBoot - PullRequest
0 голосов
/ 20 марта 2020

Я пытаюсь разработать какую-то систему уведомлений с SpringBoot с PetClini c в качестве шаблона.

Я опирался на это руководство. https://www.technicalkeeda.com/spring-boot-tutorials/how-to-send-email-using-spring-boot

Я также написал этот контроллер


import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.model.Mail;
import org.springframework.samples.petclinic.service.MailServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class MailController {

    private final MailServiceImpl mailservice;

    @Autowired
    public MailController(MailServiceImpl mailservice) {
        this.mailservice = mailservice;
    }

    @GetMapping(value = "/email")
    public String sendEmail(Map<String, Object> model) {
        Mail m = new Mail();
        m.setMailFrom("cd1b85bb23-d80bad@inbox.mailtrap.io");
        m.setMailTo("joaki.glez@gmail.com");
        m.setMailSubject("Test");
        m.setMailContent("Merry Xmas");

        this.mailservice.sendEmail(m);
        return "redirect:/welcome";
    }

}

Я получаю это на консоли:

2020-03-19 22:39:58.320  INFO 16224 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-03-19 22:39:58.341  INFO 16224 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2020-03-19 22:39:58.397  WARN 16224 --- [  restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-03-19 22:39:58.582  INFO 16224 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-03-19 22:39:58.905  INFO 16224 --- [  restartedMain] .s.s.UserDetailsServiceAutoConfiguration : 

Using generated security password: 3d1de4ac-91f6-4025-a9a1-76dca8a059ac

2020-03-19 22:39:58.917  INFO 16224 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@538a2b22, org.springframework.security.web.context.SecurityContextPersistenceFilter@320a076d, org.springframework.security.web.header.HeaderWriterFilter@330e6d10, org.springframework.security.web.csrf.CsrfFilter@12302459, org.springframework.security.web.authentication.logout.LogoutFilter@8db4446, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@1e5ca4d5, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@16d973, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@58d20889, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@56f09cf9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@3eaa9bc6, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7e0c17ee, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@2353654a, org.springframework.security.web.session.SessionManagementFilter@218bfde9, org.springframework.security.web.access.ExceptionTranslationFilter@7a1ec64c, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3c06eab0]
2020-03-19 22:39:58.983  INFO 16224 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-03-19 22:39:58.984  INFO 16224 --- [  restartedMain] o.s.s.petclinic.PetclinicApplication     : Started PetclinicApplication in 1.767 seconds (JVM running for 542.716)
2020-03-19 22:39:58.985  INFO 16224 --- [  restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged

логин ошибка

Кто-нибудь знает, где проблема?

Могу ли я реализовать более эффективный способ отправки электронной почты?

Спасибо и наилучшими пожеланиями

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...