Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem sending email outside my domain

843830Sep 25 2004 — edited Sep 29 2004
I'm having trouble with JavaMail in my JSP. I have an account with lunarpages.com. They have linux servers running Resin. My JSP will send e-mails to accounts
at my domain in lunarpages, but it won't send messages outside the domain. For example an email to joe@my_lunarpages_domain.com will make it to Joe, but an email to joe@yahoo.com will not. Any ideas?

Here's the source code:

try{
String host ="xanthe.lunarpages.com";
String from = "webmaster@mydomain.com";
String to = emailTo;
String subject = subjectText;
String message = msgText;

Properties prop =System.getProperties();
prop.put("mail.smtp.host",host);
Session ses1 = Session.getDefaultInstance(prop,null);
MimeMessage msg = new MimeMessage(ses1);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
msg.setSubject(subject);

// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();

// Fill the message
messageBodyPart.setText(message);

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);

// Part two is attachment
//messageBodyPart = new MimeBodyPart();
//DataSource source = new FileDataSource(localfile);
//messageBodyPart.setDataHandler(new DataHandler(source));
//messageBodyPart.setFileName(attachName);
//multipart.addBodyPart(messageBodyPart);

msg.setContent(multipart);
//System.out.println("...sending mail....");
Transport transport = ses1.getTransport("smtp");
transport.connect("xanthe.lunarpages.com", "webmaster@mydomain.com", "mydomainPassword");
transport.send(msg);

messageBodyPart = null;
msg = null;
prop = null;
multipart = null;
transport = null;
ses1 = null;
}
catch(javax.mail.MessagingException me){
me.printStackTrace();
}

Thanks in advance,
Jerod
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2004
Added on Sep 25 2004
4 comments
162 views