cancel
Showing results for 
Search instead for 
Did you mean: 

Getting email sending failed exception after changing SMPT server details

bhaskar_india
Participant
0 Kudos

Hi,

In a webdynpro application, the email is sent to the user on submitting the request using the below code.

                  IUMParameters er = UMFactory.getProperties();

                  String host = er.get("ume.notification.mail_host");

                 

                  /*get the system properties*/

                  Properties props = System.getProperties();

                  /*set up mail server*/

                  props.put("mail.smtp.host", host);

                  /*get session*/

                  Session session1 = Session.getInstance(props);

                  /*define message*/

                

                  MimeMessage message = new MimeMessage(session1);

          

           if((null!=fromId && !fromId.equals("")) && (null!=subject &&!subject.equals(""))&&(null!=text && !text.equals("")))

           {

             message.setFrom(new InternetAddress(fromId));

                      for (int i = 0; i < toIds.length; i++) {

                      

                        if (null!= toIds[i] && !toIds[i].equals(""))

                            

                         message.addRecipient(MimeMessage.RecipientType.TO,new InternetAddress(toIds[i]));

                       }

                   message.setSubject(subject);

                   message.setText(text, "utf-8");

                

                  javax.mail.Transport.send(message);


The SMTP server details were recently for the email sending. After changing the details an exception is thrown as below.

Sending failed;  nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;  nested exception is: java.net.ConnectException: Connection refused


Kindly help on why this error is appearing.


Regards,

Bhaskar

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

If i were you, i would first check my code is working or not by my gmail account information. When i sure that the code is working fine then i ask my system admin to give me the information of my company smtp information. As far as i see that the error appear because of your smpt information is not right.

junwu
Active Contributor
0 Kudos

localhost is your smtp server?

bhaskar_india
Participant
0 Kudos
  • ume.notification.mail_host

Reply - NWA - Identity management – configuration – Notification emails - Host Name of the SMTP Server: - empty before and after the change.

  • mail.smtp.host

Reply - has the entry “localhost” in visual admin (Java mail client – smtp mapping). This is the default value.

We tried changing this entry to point to new SMTP server and restarting the service but the error remained unchanged.

Localhost points to 127.0.0.1 in our /etc/hosts file

Old SMTP server is oldserver.org

And new SMTP server is newserver.org

junwu
Active Contributor