Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:41:39+00:00 2026-06-12T10:41:39+00:00

While writing an Email application in java I getting this exception: javax.mail.MessagingException: Could not

  • 0

While writing an Email application in java I getting this exception:

javax.mail.MessagingException: Could not connect to SMTP host: mail.simsystech.com, port: 8443;
  nested exception is:
    java.net.ConnectException: Connection timed out: connect
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:317)

& here is my code(follow this tutorial link) :

          Properties properties = System.getProperties();
          properties.put("mail.smtp.starttls.enable", "true");
          properties.put("mail.transport.protocol", "smtp");
          properties.setProperty("mail.smtp.host", host);
//        properties.put("mail.smtp.port", "8443");
          properties.setProperty("mail.smtp.auth", "true");
          properties.setProperty("mail.smtp.starttls.enable", "true");

          final String user = "abc@xyz.com";
          final String password = "*****";

          Authenticator authenticator = new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(user,password);
                }
            };


          Session session = Session.getDefaultInstance(properties,authenticator);


          try{
              MimeMessage message = new MimeMessage(session);

              message.setFrom(new InternetAddress(sid));

              message.addRecipient(Message.RecipientType.TO,
                                       new InternetAddress(rid));

              message.setSubject(subject);

              BodyPart messageBodyPart = new MimeBodyPart();

              messageBodyPart.setText(text);

              Multipart multipart = new MimeMultipart();

              multipart.addBodyPart(messageBodyPart);


              messageBodyPart = new MimeBodyPart();
//            String filename = "file.txt";
              DataSource source = new FileDataSource(file);
              messageBodyPart.setDataHandler(new DataHandler(source));
              messageBodyPart.setFileName(file);
              multipart.addBodyPart(messageBodyPart);

              // Send the complete message parts
              message.setContent(multipart );


              // Now set the actual message
//            message.setText(text);

              // Send message
              Transport.send(message);
              System.out.println("Sent message successfully....");
           }catch (MessagingException ex) {
              ex.printStackTrace();
           }

Though I have gone through these links of stackoverflow : 1, 2

Any idea why I’m getting this error… 🙁 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:41:41+00:00Added an answer on June 12, 2026 at 10:41 am

    Assuming that no network issues occur with your connection (you can use telnet to make sure of it) then…

    The problem must be because of the properties.setProperty("mail.smtp.starttls.enable", "true");

    According to javadoc of com.sun.mail.smtp ,

    If true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. Note that an appropriate trust store must configured so that the client will trust the server’s certificate. Defaults to false.

    And below says for mail.smtp.starttls.required

    If true, requires the use of the STARTTLS command. If the server doesn’t support the STARTTLS command, or the command fails, the connect method will fail. Defaults to false.

    Try removing the above property if your provider doesn’t support it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mail application. While sending to each recipient I am writing to
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common
I am writing this simple code to get alert email when "error" found on
I've been thinking about this problem for a while now and I'm still not
I'm facing one issue while writing Office Outlook 2007 Add-In, I'm accessing the email
I often face this problem.. Lets say ..In blog application, I need to email
When writing a connection to connect to the POP3 protocol through sockets, I could
While writing an encryption method in JavaScript, I came to wondering what character encoding
While writing some C code, I decided to compile it to assembly and read
While writing code in a file that would comprise of PHP, HTML, CSS &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.