|
|
 |
| 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.
|
 |

April 1st, 2009, 03:10 PM
|
|
Authorized User
|
|
Join Date: Apr 2008
Location: Brasov, Romania, Romania.
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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
|

July 7th, 2009, 11:03 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Last edited by iamrakesh22 : July 7th, 2009 at 11:09 AM.
|
|
The Following User Says Thank You to iamrakesh22 For This Useful Post:
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
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 |
|
 |