package urlshortener.aeternum.web;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

@Component
public class SendMail {

    private static String RECIPIENT = "anagonzalor@gmail.com";

    public void sendMail(String url) {
        String from = "pruprupru9@gmail.com";
        String pass = "pruprupru99";
        String[] to = { RECIPIENT }; // list of recipient email addresses
        String subject = "Warning!";
        String body = "The url " + url + " has become unsafe! To be able to visit the page go to http://localhost:8080/#/unsafePage";

        Properties props = System.getProperties();
        String host = "smtp.gmail.com";
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.host", host);
        props.put("mail.smtp.user", from);
        props.put("mail.smtp.password", pass);
        props.put("mail.smtp.port", "587");
        props.put("mail.smtp.auth", "true");

        Session session = Session.getDefaultInstance(props);
        MimeMessage message = new MimeMessage(session);

        try {
            message.setFrom(new InternetAddress(from));
            InternetAddress[] toAddress = new InternetAddress[to.length];

            // To get the array of addresses
            for( int i = 0; i < to.length; i++ ) {
                toAddress[i] = new InternetAddress(to[i]);
            }

            for( int i = 0; i < toAddress.length; i++) {
                message.addRecipient(Message.RecipientType.TO, toAddress[i]);
            }

            message.setSubject(subject);
            message.setText(body);
            Transport transport = session.getTransport("smtp");
            transport.connect(host, from, pass);
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();
        }
        catch (AddressException ae) {
            ae.printStackTrace();
        }
        catch (MessagingException me) {
            me.printStackTrace();
        }
        System.out.println("¡Correo enviado!");
    }
}

@@ -243,16 +243,98 @@
 ndMail %7B
+%0A    private static final Logger logger = LoggerFactory.getLogger(SendMail.class);
 %0A%0A    pr
@@ -2192,29 +2192,21 @@
     
-System.out.println
+logger.info
 (%22
-%C2%A1
 Corr
@@ -2218,17 +2218,16 @@
 viado!%22)
-;
 %0A    %7D%0A%7D

Update SendMail.java