title: Java Mail: Exception when sending email
body: <p>First time working with java mail. I'm following <a href="https://smartbear.com/blog/test-and-monitor/how-to-send-email-with-embedded-images-using-java/" rel="nofollow noreferrer">this tutorial</a> but I already fail at sending a basic message and I get a very strange error:</p>
  
  <pre><code>java.util.ServiceConfigurationError: javax.mail.Provider: Provider com.sun.mail.imap.IMAPProvider not a subtype
  </code></pre>
  
  <p>Strange because I'm not using IMAP anywhere in my code:</p>
  
  <pre><code>Properties mailProps = new Properties();
  mailProps.put("mail.transport.protocol", "smtp");
  mailProps.put("mail.host", "smtp.mydomain.com");
  mailProps.put("mail.from", "me@mydomain.com");
  mailProps.put("mail.smtp.port", "25");     
  
  Session session = Session.getDefaultInstance(mailProps);
  SMTPMessage m = new SMTPMessage(session);
  MimeMultipart content = new MimeMultipart();
  MimeBodyPart mainPart = new MimeBodyPart();
  mainPart.setText("test");
  content.addBodyPart(mainPart);  
  m.setContent(content);
  m.setSubject("Demo message");
  
  m.setRecipient(RecipientType.TO, new InternetAddress("john@example.com"));
  Transport.send(m);
  </code></pre>
  
  <p>The error happens on last line (send). I know the smtp server is correct and working.</p>
  
  <p>Any advice why this happens and how I can solve it?</p>
  
  <p>EDIT: obviously the addresses/hosts are changed here and I'm using real ones that work in the actual code.</p>