-
sending an email in java: (help a Beginner !)
hi,
i am new to java mail and trying to send a test mail and here's my code
Properties props = new Properties();
props.put("mail.host"," smtp ");
Session mail = Session.getInstance(props,null);
mail.setDebug(true);
final Message msg = new MimeMessage(mail);
Address to = new InternetAddress("to");
Address from = new InternetAddress("from");
msg.setFrom(from);
msg.setRecipient(Message.RecipientType.TO,to);
msg.setSubject("Java TEST ");
Transport.send(msg);
(with the assumption that i have correct details of the server and to and from addresses)
but i get the following exception :
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: smtp.host, port: 25;
nested exception is:
java.net.NoRouteToHostException: No route to host: connect
(oh, and i also have the try and catch thing for the code)
can u help?
thx
-
You have to use the name of an actual SMTP server as your mail host. Replace "smtp" with the name of an available SMTP server.
JavaMail quick start
jGuru: Fundamentals of the JavaMail API
JavaMail FAQ
Send email with JavaMail
-
as i said, i do have the actual names, i just didn't want to post it.
besides, the exception refers to something else not "server not found"
-
the smtp server is :smtp.tiscali.co.uk
-
Are you able to "see" that server from where you're running your app? Have you tried telnetting to port 25 on smtp.tiscali.co.uk?
Similar Threads
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
Replies: 2
Last Post: 09-27-2001, 09:09 AM
-
By Debbie Locker in forum Talk to the Editors
Replies: 8
Last Post: 07-24-2001, 07:50 PM
-
By Debbie Locker in forum Java
Replies: 0
Last Post: 07-18-2001, 08:47 AM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks