Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to send mail - javax.mail.NoSuchProviderException: smtp
    text
    copied!<p>I am trying to send email using apache james with this code</p> <pre><code>public static void main(String[] args) { String user = "sumit"; // Newly created user on JAMES String password = "sumit"; // user password String fromAddress = "sumit@localhost"; // newlycreateduser@localhost String toAddress = "sumitjain91@gmail.com"; // Create a mail session Properties properties = new Properties(); properties.put("mail.smtp.host", "localhost"); properties.put("mail.smtp.port", "25"); properties.put("mail.smtp.username", user); properties.put("mail.smtp.password", password); Session session = Session.getDefaultInstance(properties, null); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress(fromAddress)); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toAddress)); message.setSubject("Email from our JAMES Server"); message.setText("Luke, I'm your father!!"); Transport.send(message); System.out.println("Email sent successfully"); } catch (MessagingException e) { e.printStackTrace(); } } </code></pre> <p>I am getting the following exception </p> <pre><code>javax.mail.NoSuchProviderException: smtp at javax.mail.Session.getService(Session.java:784) at javax.mail.Session.getTransport(Session.java:720) at javax.mail.Session.getTransport(Session.java:660) at javax.mail.Session.getTransport(Session.java:640) at javax.mail.Session.getTransport(Session.java:697) at javax.mail.Transport.send0(Transport.java:192) at javax.mail.Transport.send(Transport.java:124) at mail.Main.main(Main.java:44) </code></pre> <p>Please help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload