Envio de correo estático, se agrega un campo a la tabla parameters

parent a1341af3
......@@ -24,6 +24,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.lowagie:itext:2.1.7'
implementation 'net.sf.jasperreports:jasperreports:6.9.0'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'javax.persistence:javax.persistence-api'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
annotationProcessor 'org.projectlombok:lombok'
......
package ec.edu.espe.movilidad.MovilidadWS.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static ec.edu.espe.movilidad.MovilidadWS.Constant.GlobalConstants.V1_API_VERSION;
@RestController
@CrossOrigin(origins = "*")
@RequestMapping(V1_API_VERSION+"/xd")
public class EnvioCorreosController {
@Autowired
private JavaMailSender mail;
@PostMapping("/enviarCorreo")
public ResponseEntity<?> enviarCorreo(){
SimpleMailMessage email= new SimpleMailMessage();
email.setTo(""); //Correo a quien se va a enviar
email.setFrom(""); //Correo del quien envia
email.setSubject("Mensaje prueba");
email.setText("xd");
mail.send(email);
return new ResponseEntity<>(true, HttpStatus.OK);
}
}
......@@ -26,4 +26,7 @@ public class ModelParameters {
@Column(name = "Puntaje", nullable = false)
private Integer puntaje;
@Column(name = "Activo", nullable = false)
private Boolean activo;
}
package ec.edu.espe.movilidad.MovilidadWS.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import javax.mail.internet.MimeMessage;
import javax.transaction.Transactional;
@Service
@Transactional
public class ServiceEmail {
@Autowired
JavaMailSender javaMailSender;
@Autowired
ServiceFile serviceFile;
@Value("${spring.mail.username}")
private String email;
public void sendListEmail(String emailTo){
}
}
......@@ -24,3 +24,15 @@ spring.servlet.multipart.max-file-size=5MB
#establecer el tamao maximo de varios archivos enviados a la vez de una misma solicitud
spring.servlet.multipart.max-request-size=5MB
#media.location=mediafiles
#mail
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.protocol=smtp
#spring.mail.username =
#spring.mail.password=
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
spring.main.allow-circular-references=true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment