java mail problemer på linux
Jeg har lavet et lille mailprogram men har store problemer når skidtet skal køre på linux. Alt går VIRKELIG langsomt på linuxen hvorimod på min Windows er der ingen problemer.Nogen der har erfaret noget lignende?
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
public void postEmail() throws MessagingException //sending the email
{
boolean debug = false;
try {
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", SMTP_SERVER);
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
// create a message
javax.mail.internet.MimeMessage msg = new javax.mail.internet.MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(this.from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[1];
addressTo[0] = new InternetAddress(this.to);
if (this.bcc != null) {
InternetAddress[] addressBCC = new InternetAddress[1];
addressBCC[0] = new InternetAddress(this.bcc);
msg.setRecipients(Message.RecipientType.BCC, addressBCC);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
//Setting the Subject with characterset iso-8859-1 (corrects problem with æøå in subject field)
msg.setSubject(this.subject, "iso-8859-1");
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(this.body);
MimeBodyPart mbp2 = new MimeBodyPart();
// attach the file to the message
FileDataSource fds=
new FileDataSource(this.getFilePath());
mbp2.setDataHandler(
new DataHandler(fds));
mbp2.setFileName(this.getFilePath());
// create the Multipart
//and its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
// add the Multipart to the message
msg.setContent(mp);
Transport.send(msg);
} catch (Exception ex) {
throw new MessagingException(ex.getMessage());
}
}
