com.sun.mail.smtp.SMTPAddressFailedException
11,884
It seems to me that the entered Gaetano@ConseltiGT address is not valid, probably because of a typo. I would have expected it to be something like this: [email protected] or some other extension so that the domain can actually get resolved.
Related videos on Youtube
Author by
Gaetano Tortora
Updated on June 04, 2022Comments
-
Gaetano Tortora almost 2 years
I'm trying to generate and send an automatic mail with Spring.
I have this exception when try to send email:
org.springframework.mail.MailSendException: Failed messages: javax.mail.SendFailedException: Invalid Addresses; nested exception is: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.8 <Gaetano@ConseltiGT>: Sender address rejected: Domain not found ; message exception details (1) are: Failed message 1: javax.mail.SendFailedException: Invalid Addresses;
Within the application-context.xml file, I have:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl" p:host="${email.account.host}" p:port="${email.account.port}" p:username="${email.account.username}" p:password="${email.account.password}" p:javaMailProperties-ref="javaMailProperties"/> <util:properties id="javaMailProperties"> <prop key="mail.smtp.auth">${email.account.smtp.auth}</prop> <prop key="mail.smtp.starttls.enable">${email.account.smtp.starttls.enable}</prop> </util:properties>
Within the service I have:
@Service @Slf4j public class EmailSenderTUService { @Autowired private JavaMailSender mailSender; private String messageDefault = "Il sistema TESORERIA UNICA TELEMATICA richiede attenzione\n"; public void sendMail(String subj, String msg) { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message); try { helper.setTo("[email protected]"); helper.setSubject(subj); helper.setText(messageDefault + msg); } catch (MessagingException e) { log.error("ERRORE Invio email", e); } mailSender.send(message); } }
Suggestions?