Hi all,
Can anyone help me in this??
While I am running a simple
java mail send application I am getting an error saying..
----------------------Error message------------------------------
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: 172.16.65.1, port: 80
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at SimpleSender.send(SimpleSender.java:41)
at SimpleSender.main(SimpleSender.java:61)
----------------------End of message------------------------------
I have changed the port from default 25 to 80 since my proxy server port number is 80.
The complete source is given below..
//---------------Source for SimpleSender.java--------------------
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class SimpleSender
{
public static void send(
String smtpServer, String to, String from, String subject, String body)
{
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.port", "80");
Session session = Session.getDefaultInstance(props, null)
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse
(to,false));
Transport.send(msg);
System.out.println("Message sent OK.");
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public static void main(String args[])
{
String smtpServer="172.16.65.1";
String to="
[email protected]";
String from="
[email protected]";
String subject="hi";
String body="This is just a trail HI...";
send(smtpServer, to, from, subject, body);
}
}
//---------------------End or SimpleSender.java----------------------