Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2009, 02:10 PM
Authorized User
 
Join Date: Apr 2008
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default sendEmail problem

I want to send email from a server using smtp protocol. This server has a user name and a password. I have some problems :
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.mail.NoSuchProviderException: Invalid protocol: null
org.apache.struts.action.RequestProcessor.processE xception(RequestProcessor.java:535)

Code :

if (Rs != null && Rs.next())
{
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", "mail.eurosystemsdevelopment.com");
props.put("auth", "true");

SMTPAuthenticator sm = new SMTPAuthenticator("ggg@jjjjjj.com","werwerwer");


Session mailSession = Session.getDefaultInstance(props,sm);

Transport transport = mailSession.getTransport();

MimeMessage message = new MimeMessage(mailSession);
message.setContent("Your password is " + Rs.getString("Password"), "text/plain");
message.setFrom(new InternetAddress("xxx@yyyy.com"));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(f.getUserEmail()));

transport.connect();
transport.sendMessage(message,
message.getRecipients(Message.RecipientType.TO));
transport.close();
request.setAttribute("emailSent", "Email was sent succesfully");
}

the SMTPAuthenticator class :


import javax.mail.PasswordAuthentication;

public class SMTPAuthenticator extends javax.mail.Authenticator {
String username;
String password;

public SMTPAuthenticator(String username, String password)
{
this.username = username;
this.password = password;
}

public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(this.username, this.password);
}
}


Any ideas? Thank you
__________________
Thank you
 
Old July 7th, 2009, 10:03 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

These links might help

http://www.theserverside.com/discuss...hread_id=33596
http://forums.sun.com/thread.jspa?threadID=5373266

using java mail
http://www.nakov.com/inetjava/lectur...aMail-API.html
__________________
- Rakesh
http://iam-rakesh.blogspot.com

Last edited by iamrakesh22; July 7th, 2009 at 10:09 AM..
The Following User Says Thank You to iamrakesh22 For This Useful Post:
Aker (July 7th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
sendEmail Function in DTS gemispence SQL Server 2000 0 February 21st, 2006 05:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.