Sending email question,
843830Sep 6 2004 — edited Sep 7 2004Hi 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