content: package com.activecourses.upwork.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.PropertySource;
  import org.springframework.mail.javamail.JavaMailSender;
  import org.springframework.mail.javamail.JavaMailSenderImpl;
  import org.springframework.beans.factory.annotation.Value;
  
  import java.util.Properties;
  
  @Configuration
  @PropertySource("classpath:env.properties")
  public class MailConfig {
  
      @Value("${spring.mail.username}")
      private String username;
  
      @Value("${spring.mail.password}")
      private String password;
      
      @Bean
      public JavaMailSender getJavaMailSender() {
          JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
          mailSender.setHost("smtp.gmail.com");
          mailSender.setPort(587);
  
          mailSender.setUsername(username);
          mailSender.setPassword(password);
  
          Properties props = mailSender.getJavaMailProperties();
          props.put("mail.transport.protocol", "smtp");
          props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.starttls.enable", "true");
          props.put("mail.debug", "true");
  
          return mailSender;
      }
  }
  