Zanderfilet
Grünschnabel
Hallo,
hab obiges Problem, arbeite mit eclipse, die mail.jar sowie activator.jar (zur sicherheit) pfade sind angegeben.
Code:
Nur die verkürzte Form...aber da es schon bei Authentficator hackt reicht des wohl...
Es handelt sich um eine Standalone Applikation...kein J2EE oder ähnliches..
Irgendeine Idde woran es liegen könnte?
hab obiges Problem, arbeite mit eclipse, die mail.jar sowie activator.jar (zur sicherheit) pfade sind angegeben.
Code:
Java:
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.mail.Authenticator;
import java.io.*;
public class MailCommunicator
{
public void postMail( String recipients[ ], String subject,
String message , String from) throws MessagingException
{
boolean debug = false;
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.web.de");
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++)
{
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
}
Es handelt sich um eine Standalone Applikation...kein J2EE oder ähnliches..
Irgendeine Idde woran es liegen könnte?
Zuletzt bearbeitet von einem Moderator: