my mail are going only to my id's in my domain. what could be the problem

my progam works fine if i mailing id belongs to my domain. it does not work if it is outside the domain. what could be the possible problem. i have presented my code below.

import javax.mail.*;

import javax.mail.internet.*;

import java.util.*;

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

publicclass SMTPClientextends JFrame{

private JButton sendButton =new JButton("Send Message");

private JLabel fromLabel =new JLabel("From: ");

private JLabel toLabel =new JLabel("To: ");

private JLabel hostLabel =new JLabel("SMTP Server: ");

private JLabel subjectLabel =new JLabel("Subject: ");

private JTextField fromField =new JTextField(40);

private JTextField toField =new JTextField(40);

private JTextField hostField =new JTextField(40);

private JTextField subjectField =new JTextField(40);

private JTextArea message =new JTextArea(40, 72);

private JScrollPane jsp =new JScrollPane(message);

public SMTPClient( ){

super("SMTP Client");

Container contentPane = this.getContentPane( );

contentPane.setLayout(new BorderLayout( ));

JPanel labels =new JPanel( );

labels.setLayout(new GridLayout(4, 1));

labels.add(hostLabel);

JPanel fields =new JPanel( );

fields.setLayout(new GridLayout(4, 1));

String host = System.getProperty("mail.host","");

hostField.setText(host);

fields.add(hostField);

labels.add(toLabel);

fields.add(toField);

String from = System.getProperty("mail.from","");

fromField.setText(from);

labels.add(fromLabel);

fields.add(fromField);

labels.add(subjectLabel);

fields.add(subjectField);

Box north = Box.createHorizontalBox( );

north.add(labels);

north.add(fields);

contentPane.add(north, BorderLayout.NORTH);

message.setFont(new Font("Monospaced", Font.PLAIN, 12));

contentPane.add(jsp, BorderLayout.CENTER);

JPanel south =new JPanel( );

south.setLayout(new FlowLayout(FlowLayout.CENTER));

south.add(sendButton);

sendButton.addActionListener(new SendAction( ));

contentPane.add(south, BorderLayout.SOUTH);

this.pack( );

}

class SendActionimplements ActionListener{

publicvoid actionPerformed(ActionEvent evt){

//System.out.println("event trigered" + evt.getSource());

try{

Properties props =new Properties( );

props.put("mail.host", hostField.getText( ));

Session mailConnection = Session.getInstance(props,null);

Message msg=new MimeMessage(mailConnection);

Address to =new InternetAddress(toField.getText( ));

Address from =new InternetAddress(fromField.getText( ),"Prakash Anandaraj C");

msg.setContent(message.getText( ),"text/plain");

msg.setFrom(from);

msg.setRecipient(Message.RecipientType.TO, to);

msg.setSubject(subjectField.getText( ));

Transport.send(msg);

message.setText("");

// This can take a non-trivial amount of time so

// spawn a thread to handle it.

/*Runnable r = new Runnable( ) {

public void run( ) {

try {

}

catch (Exception e) {

e.printStackTrace( );

}

}

};

Thread t = new Thread(r);

t.start( );*/

}

catch (Exception e){

// We should really bring up a more specific error dialoghere.

e.printStackTrace( );

}

}

}

publicstaticvoid main(String[] args){

SMTPClient client =new SMTPClient( );

// Next line requires Java 1.3. We want to set up the

// exit behavior here rather than in the constructor since

// other programs that use this class may not want to exit

// the application when the SMTPClient window closes.

client.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

client.setVisible(true);

}

}

Thanks in advance

[6938 byte] By [prakash_ruleza] at [2007-10-3 3:45:43]
# 1
Check your mail server configuration, whether external mail can be send with your mail ID or the IP address is in Block list.
ragas32a at 2007-7-14 21:42:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Go to the JavaMail FAQ and read about relaying.
DrClapa at 2007-7-14 21:42:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Most likely this is caused by relaying.in your code add:mailConnection.setDebug(true);directly after your definition of mailConnection and you should get some useful information on stdout/stderr.
travis_fergusona at 2007-7-14 21:42:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Thank you, it was of great help . the problem was without authentication i could send mail only internal mail. i need to get authentication before proceeding furtherthanks to each one of you for your response
prakash_ruleza at 2007-7-14 21:42:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...