5
respostas

Erro 500 - Must issue a STARTTLS command first

Ao finalizar compra ocorre:

Pagamento efetuado com sucesso
nov 01, 2019 3:36:56 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet [dispatcher] threw exception
org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. v16sm4395084qth.51 - gsmtp
; message exception details (1) are:
Failed message 1:
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. v16sm4395084qth.51 - gsmtp

Minha configuração é:

mailSender.setHost("smtp.gmail.com");
        mailSender.setUsername("CCLOCAWEB.com.br");
        mailSender.setPassword("CCLOCAWEBSENHA");
        mailSender.setPort(587);

        Properties mailProperties = new Properties();
        mailProperties.put("mail.smtp.auth", true);
        mailProperties.put("mail.smpt.starttls.enable", true);

Coloco meu e-mail corporativo e senha mas lança Exception e não recebo o e-mail

5 respostas

Oi Jhony, tudo bem?

Tenta incluir essas properties:

Properties mailProperties = new Properties();  
        mailProperties.put("mail.smtp.host", "smtp.gmail.com");  
        mailProperties.put("mail.smtp.auth", "true");  
        mailProperties.put("mail.smtp.port", "465");  
        mailProperties.put("mail.smtp.starttls.enable", "true");  
        mailProperties.put("mail.smtp.socketFactory.port", "465");  
        mailProperties.put("mail.smtp.socketFactory.fallback", "false");  
        mailProperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

Não funcionou

Tentei alterar as informações de smtp e não tive sucesso novamente:

Properties mailProperties = new Properties();  
        mailProperties.put("mail.smtp.host", "smtp.[omitido].com.br");  
        mailProperties.put("mail.smtp.auth", "true");  
        mailProperties.put("mail.smtp.port", "465");  
        mailProperties.put("mail.smtp.starttls.enable", "true");  
        mailProperties.put("mail.smtp.socketFactory.port", "465");  
        mailProperties.put("mail.smtp.socketFactory.fallback", "false");  
        mailProperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
Type Exception Report

Message Request processing failed; nested exception is org.springframework.mail.MailSendException: Failed messages: javax.mail.SendFailedException: Invalid Addresses;

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.mail.MailSendException: Failed messages: javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 453 4.7.1 <[email omitido].com.br>: Recipient address rejected: Access Denied

Referente ao último erro enviado:

com.sun.mail.smtp.SMTPAddressFailedException: 453 4.7.1 <[email omitido].com.br>: Recipient address rejected: Access Denied

Creio que você tenha esquecido de voltar o valor correto:

smtp.[omitido].com.br

Eu coloquei omitido manualmente antes de postar para evitar expor o e-mail da empresa, vou tentar usar credenciais do meu gmail e respondo

Habilitei no meu Google acesso à aplicações menos seguras e configurei minha conta particular, ocorreu o seguinte erro:

Message Request processing failed; nested exception is org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials l62sm5452788qkc.9 - gsmtp

Minhas credenciais estão corretas (alterei manualmente antes de postar, mas no meu eclipse estão corretas):

mailSender.setHost("smtp.gmail.com");
        mailSender.setUsername("jhony.v@gmail.com");
        mailSender.setPassword("omitido");
        mailSender.setPort(587);

        Properties mailProperties = new Properties();  
        mailProperties.put("mail.smtp.host", "smtp.gmail.com");  
        mailProperties.put("mail.smtp.auth", "true");  
        mailProperties.put("mail.smtp.port", "465");  
        mailProperties.put("mail.smtp.starttls.enable", "true");  
        mailProperties.put("mail.smtp.socketFactory.port", "465");  
        mailProperties.put("mail.smtp.socketFactory.fallback", "false");  
        mailProperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");