Expand my Community achievements bar.

SOLVED

Failing to resolve mail dependency

Avatar

Level 1

I have a bundle that has a service that sends email using javamail library in ISO-2022-JP encoding and a servlet that invokes this service to send emails. The bundle has mail-1.4.1.jar dependency defined in pom.xml.  When I am hitting the servlet URL, email is sent properly. 

e.g. http://localhost:4502/bin/jpemailiso?to=TO_EMAIL&from=FROM_EMAIL&subject=437%E3%81%AA%E3%81%9F%E3%81... 

when I hit this url, email is sent successfully.

But when I am trying to invoke the service directly in a form action POST.jsp, I am getting the following error:

javax.mail.NoSuchProviderException: smtp
at javax.mail.Session.getService(Session.java:794)
at javax.mail.Session.getTransport(Session.java:718)
at javax.mail.Session.getTransport(Session.java:661)
at javax.mail.Session.getTransport(Session.java:641)
at javax.mail.Session.getTransport(Session.java:696)
at javax.mail.Transport.send0(Transport.java:186)
at javax.mail.Transport.send(Transport.java:118)

Not sure why is this happening. What would be the difference in invoking the service from a servlet and POST.jsp. Please help me on this.

1 Accepted Solution

Avatar

Correct answer by
Level 2

your servlet may not be implmenting the sling SCR annotations .

http://sling.apache.org/documentation/the-sling-engine/servlets.html

there are two ways to do this ..

1) as a component .. where your servlet gets called all the time and you implement your logic in doPost()

2) write an osgi bundle and run it as a mail service to reference it later

- Venu Gummadala

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

your servlet may not be implmenting the sling SCR annotations .

http://sling.apache.org/documentation/the-sling-engine/servlets.html

there are two ways to do this ..

1) as a component .. where your servlet gets called all the time and you implement your logic in doPost()

2) write an osgi bundle and run it as a mail service to reference it later

- Venu Gummadala