aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes javax.mail package Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "javax.mail package" Watch "javax.mail package" New topic
Author

javax.mail package

sukdev painuly
Greenhorn

Joined: Oct 02, 2001
Posts: 2
I am new mail package user.
I'm using javax.mail package to send mail through internet.I'm using proxy server on windows.But I am getting unknown smtp host exception and sendingexception .
I'm using SMTP protocol for sending mails.
My code is as follows.....................

import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMail
{
public static void main (String args[]) throws Exception
{
String host = "mail.im.eth.net";
String from = "sandiprane@yahoo.com";
String to = "sandeep9678@rediffmail.com";
Properties props = System.getProperties();
props.put("mail.transport.protocol","smtp");
props.put("mail.smtp.host", host);
Session session = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
System.out.println(" setting subject and message ");
message.setSubject("hi ");
message.setText("how r u");

Transport.send(message);
System.out.println(" sent the message ");
System.out.println(" thanks ");
}
}

thanks
Jared Krull
Ranch Hand

Joined: Sep 28, 2001
Posts: 32
Are you sure that "mail.im.eth.net" allows relaying for "sandeep9678@rediffmail.com"?
Find the SMTP server for "..rediffmail.com" and see if it works on that.


C programmer gone astray
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.mail package
 
Similar Threads
working example for sending mail from behind the proxy
Access the web.xml
Using Java Mail Could not connect to SMTP Host
how to send mail using gmail server
SocketException with JavaMail