•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 427,225 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,233 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1833 | Replies: 4
![]() |
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Dear all,
I am about to implement a user feedback page, by using the smtp server of my university.
When I try to send a form, an error message is received as below:
Could not connect to SMTP host: smtp-auth.bris.ac.uk, port: 587
I tested with telnet this smtp address, along with the port number.
This works fine, I can connect to it. Besides, I configured an email client where I set up the right protocol TLS/STARTTLS, and I used my username/password. It is also working fine.
So, the problem might be with my embedded Java code in JSP.
First of all, I tested my web server to send a test email in JSP without SMTP authentication. This works fine.
But, I am not able to find out what is wrong/missing in my code below to send successfully messages with authentication.
Please have a look at it, and any recommendation is welcome!
Thank you very much, in advance.
Norbert
I am about to implement a user feedback page, by using the smtp server of my university.
When I try to send a form, an error message is received as below:
Could not connect to SMTP host: smtp-auth.bris.ac.uk, port: 587
I tested with telnet this smtp address, along with the port number.
telnet smtp-auth.bris.ac.uk 587
So, the problem might be with my embedded Java code in JSP.
First of all, I tested my web server to send a test email in JSP without SMTP authentication. This works fine.
But, I am not able to find out what is wrong/missing in my code below to send successfully messages with authentication.
Please have a look at it, and any recommendation is welcome!
import="java.util.*;
import="java.io.*;
import="javax.mail.*;
import="javax.event.*;
import="javax.mail.internet.*;
import="java.security.Security.*;
import="javax.activation.*;
Properties props = new Properties();
props.put("mail.smtp.host", "smtp-auth.bris.ac.uk");
props.put("mail.smtp.port","587");
props.put("mail.debug", "true");
props.put("mail.smtp.debug", "true");
props.put ("mail.smtp.starttls.enable", "true");
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.socketFactory.port", "587");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Authenticator auth = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("myUsername", "myPassword");
}
};
Session s = Session.getInstance(props,auth);
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("myFriendAddress");
message.setFrom(from);
InternetAddress to = new InternetAddress("myAddress");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
message.saveChanges();
Transport transport = s.getTransport("smtp");
transport.connect("smtp-auth.bris.ac.uk","myUsername","myPassword");
transport.sendMessage(message,message.getAllRecipients());
transport.close();
Thank you very much, in advance.
Norbert
Last edited by webmania_bt : Jun 27th, 2008 at 8:43 am. Reason: mispelling
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 199
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 199
•
•
Join Date: Jan 2008
Posts: 12
Reputation:
Rep Power: 0
Solved Threads: 0
This page has code to send mail from GMail SMTP. Copy the code and run it.
If necessary add some concatenation operator.
http://jspcodes.elementfx.com/codesn...d=7&category=1
If necessary add some concatenation operator.
http://jspcodes.elementfx.com/codesn...d=7&category=1
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
advertisment authentication botnet browser business chain mail daniweb email encryption eu eudora expose firefox gmail google imap india mail malware microsoft mobile mozilla naked news onecare open source opinion penelope phishing piracy professional qmail research scam security server smtp sony spam spammers spamming stocks technology thunderbird uk.government video virus visa web webmail
- Previous Thread: Login to yahoo.com by providing username and password by jsp
- Next Thread: Connection to database



Linear Mode