package com.codenetworkz.portfoliowebsite.services.impl;

import com.codenetworkz.portfoliowebsite.services.EmailSendService;
import lombok.Value;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;


@Service
public class EmilSendServiceImpl implements EmailSendService {

    private final MailSender mailSender;

    EmilSendServiceImpl(MailSender mailSender){
        this.mailSender = mailSender;
    }

    @Override
    public void sendEmail(String to, String subject, String message, String from) {
        SimpleMailMessage mailMessage=new SimpleMailMessage();
        mailMessage.setTo(to);
        mailMessage.setSubject(subject);
        mailMessage.setFrom(from);
        mailMessage.setText(message);
        mailSender.send(mailMessage);
    }
}
