java mail problem

P

puropagol

I wrote the following simple java mail program. While using the
program on Windows it is working fine with our ISP, but when I am
trying to run this on a solaris box .. I am getting a
javax.mail.MessagingException saying could not connect to mail host.
Both the machines are on the internet. Can anybody suggest what the
problem is ?

******************************************************************************
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

import com.sun.mail.smtp.SMTPTransport;

public class SendMail {

public static void sendMail(
String mailHost,
int mailPort,
String userName,
String password,
String from,
String to,
String subject,
String body) {

try {
Properties prop = System.getProperties();
prop.put("mail.smtp.host", mailHost);
Session session1 = Session.getInstance(prop, null);
MimeMessage msg = new MimeMessage(session1);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));
msg.setSubject(subject);
msg.setContent(body, "text/plain");
SMTPTransport trans = new SMTPTransport(session1,new
URLName(mailHost));
trans.connect(mailHost,mailPort,userName,password);
System.out.println(trans.isConnected());
trans.sendMessage(msg, msg.getAllRecipients());
trans.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
******************************************************************************
 
M

Mikkel Heisterberg

I would start verifying the connection to SMTP server from the Solaris
box using telnet.

lekkim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

java mail api 3
java mail 6
java mail replyTo problem 2
Java mail problem 6
E-mail sending problem. 0
javax mail smtp + proxy auth problem 0
JavaMail Encoding Setting 0
java send html mail problem 3

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top