F
flupke
Guest
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)
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)