0

I'm trying to send mail from Spring web application and unsuccessfully.I'm trying to send mail to external email ids(below configurations are working perfectly with internal email ids), with Exchange from Spring web application deployed on Tomcat server through port 25 with no authentication, no SSL.

important

abcd.com is internal domain zxc.com is external domain

Error sendFailedException: Invalid Addresses

*Log

DEBUG SMPT : Valid Unsent Addresses

DEBUG SMPT : tharaka@abcd.com

DEBUG SMPT : dinesh@abcd.com

DEBUG SMPT : Invalid Addresses

DEBUG SMPT : hoon@zxc.com

DEBUG SMPT : wong@zxc.com

DEBUG SMPT : Sending failed becaouse of invalid destination addresses.*

I'm using:

Spring - 4.2.6.RELEASE javax.mail-api - 1.5.5 mail - 1.4.7

code

@Bean

public JavaMailSender getMailSender() {

JavaMailSenderImpl mailSender = new JavaMailSenderImpl();

Properties javaMailProperties = new Properties();
javaMailProperties.put("mail.smtp.host", "smtp.abcd.com");
javaMailProperties.put("mail.smtp.port", "25");
javaMailProperties.put("mail.debug", "true");

mailSender.setJavaMailProperties(javaMailProperties);

return mailSender;

}

log file

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.abcd.com", port 25, isSSL false
220 W01G.test**s.com Microsoft ESMTP MAIL Service ready at Sat, 9 Sep 2017 20:55:18 +0800
DEBUG SMTP: connected to host "smtp.abcd.com", port: 25

EHLO x01gdcimapp1a
250-W01G.test**s.com Hello [10.56.198.28]
250-SIZE 10485760
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "10485760"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<imsdc@abcd.com>
250 2.1.0 Sender OK
RCPT TO:<cbowers@zxc.com>
550 5.7.1 Unable to relay
RCPT TO:<mpsantos@zxc.com>
550 5.7.1 Unable to relay
RCPT TO:<debbaes@zxc.com>
550 5.7.1 Unable to relay
RCPT TO:<chongkheng@zxc.com>
550 5.7.1 Unable to relay
RCPT TO:<cherhengc@zxc.com>
550 5.7.1 Unable to relay
RCPT TO:<tharakadinesh@abcd.com>
250 2.1.5 Recipient OK
RCPT TO:<pdcsecurity@abcd.com>
250 2.1.5 Recipient OK
RCPT TO:<siewfernfang@abcd.com>
250 2.1.5 Recipient OK
RCPT TO:<wenmengkohkoh@abcd.com>
250 2.1.5 Recipient OK
DEBUG SMTP: Valid Unsent Addresses
DEBUG SMTP:   tharakadinesh@abcd.com
DEBUG SMTP:   pdcsecurity@abcd.com
DEBUG SMTP:   siewfernfang@abcd.com
DEBUG SMTP:   wenmengkohkoh@abcd.com
DEBUG SMTP: Invalid Addresses
DEBUG SMTP:   cbowers@zxc.com
DEBUG SMTP:   mpsantos@zxc.com
DEBUG SMTP:   debbaes@zxc.com
DEBUG SMTP:   chongkheng@zxc.com
DEBUG SMTP:   cherhengc@zxc.com
DEBUG SMTP: Sending failed because of invalid destination addresses
RSET
250 2.0.0 Resetting
DEBUG SMTP: MessagingException while sending, THROW: 
javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay

    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1996)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1240)
    at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:448)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:362)
    at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:350)
    at com.abcd.dcim.mail.MailServiceImpl.sendEmail(MailServiceImpl.java:105)
    at com.abcd.dcim.mail.DCIMSMailServiceImpl$3.run(DCIMSMailServiceImpl.java:62)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay

    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1849)
    ... 10 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay

    ... 11 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay

    ... 11 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay

    ... 11 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay

    ... 11 more
QUIT
221 2.0.0 Service closing transmission channel
Failed messages: javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Tharaka
  • 189
  • 2
  • 4
  • 20
  • Can you add the complete exception log? – juanlumn Sep 09 '17 at 10:16
  • hi juanlumn, I have updated the log file. – Tharaka Sep 09 '17 at 13:10
  • Possible duplicate of [Exception in sending emails from java application : Relaying denied](https://stackoverflow.com/questions/21884126/exception-in-sending-emails-from-java-application-relaying-denied) – juanlumn Sep 09 '17 at 13:15
  • The [JavaMail FAQ](https://javaee.github.io/javamail/FAQ#norelay) is your friend. – Bill Shannon Sep 10 '17 at 06:32
  • JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); // Using PROD. mailSender.setHost("smtp.abcd.com"); mailSender.setPort(25); mailSender.setUsername("imsdc@abcd.com"); mailSender.setPassword("test017"); Properties javaMailProperties = new Properties(); javaMailProperties.put("mail.smtp.starttls.enable", "false"); javaMailProperties.put("mail.smtp.auth", "false"); javaMailProperties.put("mail.transport.protocol", "smtp"); javaMailProperties.put("mail.debug", "true"); // – Tharaka Sep 11 '17 at 02:07
  • I have changed the configuration like above and downgraded mail - 1.4.1, Now. it's working fine in UAT, but for working in a PROD. There is a error in production "java.lang.noclassdeffounderror: com.sun.mail.uti.maillogger" – Tharaka Sep 11 '17 at 02:11

0 Answers0