Ja undskyld jeg svarer så mange gange, men jeg synes denne problem stilling er interessant derfor forsøger jeg ihærdigt at finde en løsning.
her er en god igen:
Q: I need to authenticate to my SMTP server so I call trans.connect(host, user, password) and then trans.send(msg) to send the message, but it\'s not working.
A: You should call msg.saveChanges() and then trans.sendMessage(msg) to send the message. As described above, the send method is a static convenience method that acquires its own Transport object and creates its own connection to use for sending; it does not use the connection associated with any Transport object through which it is invoked. And of course don\'t forget to set the mail.smtp.auth property to true to enable SMTP authentication!
er forresten fra:
http://java.sun.com/products/javamail/FAQ.html#Exchange-loginHov, denne her er måske en løsning med kode endda:
Du skal vist bare ændre servername,username og password.
p.s. jeg holder lige en pause indtil jeg har fået en tilbage melding.
Properties props = System.getProperties();
props.put(\"mail.smtp.auth\", \"true\");
props.put(\"mail.transport.protocol\", \"smtp\");
Session session = Session.getDefaultInstance(props, null);
try
{
MimeMessage msg = new MimeMessage(session);
msg.setText(\"Secure Email Test\");
msg.setFrom(new InternetAddress(\"username@domain.com\"));
InternetAddress[] address = {new
InternetAddress \"user@otherdomain.com\")};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(\"Test\");
msg.setSentDate(new Date());
msg.saveChanges();
Transport transport = session.getTransport();
transport.connect(smtp_mail_host, username, password);
transport.sendMessage(msg, address);
transport.close();
}
catch (MessagingException mex) {}