p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Java > Java and JDK > JSP Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 1st, 2009, 03:10 PM
Authorized User
Points: 68, Level: 1
Points: 68, Level: 1 Points: 68, Level: 1 Points: 68, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2008
Location: Brasov, Romania, Romania.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 7th, 2009, 11:03 AM
Friend of Wrox
Points: 1,108, Level: 13
Points: 1,108, Level: 13 Points: 1,108, Level: 13 Points: 1,108, Level: 13
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 363
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 11:09 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to iamrakesh22 For This Useful Post:
Aker (July 7th, 2009)
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sendEmail Function in DTS gemispence SQL Server 2000 0 February 21st, 2006 05:38 PM
SendEmail Nitin_sharma ASP Forms 4 November 22nd, 2004 06:38 PM



All times are GMT -4. The time now is 02:45 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc