@Autowired
private MailService mailService;[![enter image description here][2]][2]
public void sendMailConfirm(String receiverAddress, int orderId) {
Mail mail = new Mail();
mail.setMailFrom(senderAddress);
mail.setMailTo(receiverAddress);
mail.setMailSubject(mailSubject);
mail.setMailContent(mailContent + "\n\nOrder ID: " + orderId);
mailService.sendMail(mail);
}
My Mail class
public class Mail {
private String mailFrom;
private String mailTo;
private String mailSubject;
private String mailContent;
private String contentType;
private List<Object> attachments;
getter & setter
I wrote this in an API. But when I test this. It returns a null exception. Please help me!
// send mail to notif success order
Manager manager = new Manager();
manager.sendMailConfirm(orderVM.getEmail(), order.getId());


newsuggests you are not using spring the correct wayorderormailServicecould be null, but that is a guess. Could you please share all the code that will reproduce this issue . Please try to improve the question with enough information to help you outorderVM.getEmail()andorder.getId()always return result not null. Why the function can get null?attachmentsis null when I'm sending the order.