Skip to content
Advertisement

Java Mail: Exception when sending email

First time working with java mail. I’m following this tutorial but I already fail at sending a basic message and I get a very strange error:

JavaScript

Strange because I’m not using IMAP anywhere in my code:

JavaScript

The error happens on last line (send). I know the smtp server is correct and working.

Any advice why this happens and how I can solve it?

EDIT: obviously the addresses/hosts are changed here and I’m using real ones that work in the actual code.

Advertisement

Answer

it turns out I was running into multiple issues:

  1. Issue with tutorial

It uses com.sun.mail.smtp.SMTPMessage but in my case that doesn’t work but using javax.mail.internet.MimeMessage works fine.

  1. Root cause of error

Above code runs within a 3rd party eclipse based application and they seem to interfere with each other. The solution for this can be found here:

JavaScript

Adjusting the code accordingly make it work.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement