Tomcat throws " javax.mail.NoSuchProviderException: No provider for smtp"
|
Dec 9, 2008, 01:40 AM
|
|
|---|---|
flupke Senior Member Join: Feb 2007 Posts: 246 |
Tomcat throws " javax.mail.NoSuchProviderException: No provider for smtp" Hello, customer tries to send email over Tomcat, no luck up to now, Tomcat throws an exception 'no provider for SMTP'. "Transport transport = mailSession.getTransport("smtp");" causes the exceptions. It is an internal Tomcat issues (path, authorization to use smtp...) but not to Qmail. Any Tomcat guru with advises? Here the code and exception implementation of sendMail method: > > ppublic static boolean sendMail( String mailSmtp, String mailFrom, > String mailTo, > String mailSubject, String mailMessage ) throws Exception > { > try { > String host = "DOMAIN"; > String user = "usrer"; > String pass = "xxxx"; > boolean sessionDebug = true; > > Properties properties = new Properties(); > properties.put( "mail.smtp.host", mailSmtp ); > properties.put("mail.transport.protocol", "smtp"); > properties.put( "mail.from", mailFrom ); > properties.put("mail.smtp.auth", "true"); > > Session mailSession = Session.getInstance( properties, null ); > mailSession.setDebug(sessionDebug); > > InternetAddress[] mailAddress = { new InternetAddress( mailTo ) }; > SMTPMessage message = new SMTPMessage( mailSession ); > message.setRecipients( Message.RecipientType.TO, mailAddress ); > message.setFrom( new InternetAddress( mailFrom ) ); > message.setSubject( mailSubject ); > message.setContent( mailMessage, "text/html" ); > message.setSentDate( new Date() ); > > Transport transport = mailSession.getTransport("smtp"); > transport.addConnectionListener( new ConnectionHandler() ); > transport.addTransportListener( new TransportHandler() ); > transport.connect(host, user, pass); > transport.sendMessage( message, mailAddress ); > transport.close(); > } catch ( Exception ex ) { > System.out.println("SendMail Exception " + ex.getMessage()); > return false; > } > > return true; > } > > > > --------- exception ------- > > The statement " Transport transport = > mailSession.getTransport("smtp");" causes the excpetion: > > javax.mail.NoSuchProviderException: No provider for smtp > at javax.mail.Session.getProvider(Session.java:289) > at javax.mail.Session.getStore(Session.java:363) > at SimpleClient.main(SimpleClient.java:118) |
|
Dec 26, 2008, 03:32 PM
|
|
|---|---|
gorilych Member Join: Aug 2006 Posts: 76 |
JavaMail libraries has to be installed according to instructions from tomcat documentation: http://tomcat.apache.org/tomcat-5.5-...ces-howto.html In short it is needed to copy mail.jar and activation.jar to /usr/share/tomcat5/common/lib/ Of course you will need to restart tomcat after that. |
|
Dec 28, 2008, 02:01 AM
|
|
|---|---|
dolivia Junior Member Join: Dec 2008 Posts: 1 |
Geneo, We use NGASI AppServer Manager for our Java Hosting. One of the features is configuring the Mail object for applications to access. So you don't have to become a java export. Their website is http://www.ngasi.com. It works with Plesk, which we use for general web site management. |
« Previous Thread | Next Thread »
| Search this thread | Forum jump |
|---|---|
| Thread tools | Display modes |
|---|---|
|
Linear Mode
|