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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Sending email question,

843830Sep 6 2004 — edited Sep 7 2004
Hi everyone,
I have written an application that automatically sends email at some point. It works fine except that it's originally written to use dial-up internet connection (Earthlink). I now have cable internet provided by Adelphia and I cannot figure out what changes I need to make so that this application functions. This is the code so if someone can help I'd appreciate. Thanks, D.

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

public class EmailSender {

public static void sendEmails(String recipients[], String bodyMessage)
throws MessagingException,NoSuchProviderException {

try {

// Get system properties
Properties properties = System.getProperties();

// Setup mail server
properties.put("mail.smtp.host", "smtpauth.earthlink.net");
properties.put("mail.smtp.auth", "true");

// Get session
Session session = Session.getDefaultInstance(properties, null);

// Define message
MimeMessage message = new MimeMessage(session);
for (int i=0;i<recipients.length;i++) {
message.addRecipient(Message.RecipientType.BCC, new
InternetAddress(recipients));
}

// Set the from address
message.setFrom(new InternetAddress("Meeting@Scheduling.com"));

// Set the subject
message.setSubject("Meeting Info");
message.setSentDate(new Date());

// Set the content
message.setText(bodyMessage);

// Send message
Transport transport = session.getTransport("smtp");
transport.connect
("smtpauth.earthlink.net", "username@earthlink.net", "password");
message.saveChanges();
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}


P.S.

I am not sure but I think Adelphia SMTP server is mail.adelphia.net
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2004
Added on Sep 6 2004
3 comments
177 views