~{Blackangel}~ UT
27-05-2004, 15:41
come da titolo ecco il codice riguardante appunto javamail:
String smtpHost = "mail.server.it"; <-- dati indicativi nn sono
String from = "myemail@tiscali.it"; quelli veri :P
String to = "myemail@tiscali.it";
String filename = "c:\\demo.exe";
Properties props = System.getProperties();
props.put("mail.tiscali.it", smtpHost); penso che l'errore sia qui
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello this is a mail message");
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Here's the file");
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
ecco l'errore del compilatore:
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at jaja.main(jaja.java:105)
un grazie a tutti:cry:
String smtpHost = "mail.server.it"; <-- dati indicativi nn sono
String from = "myemail@tiscali.it"; quelli veri :P
String to = "myemail@tiscali.it";
String filename = "c:\\demo.exe";
Properties props = System.getProperties();
props.put("mail.tiscali.it", smtpHost); penso che l'errore sia qui
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello this is a mail message");
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Here's the file");
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
ecco l'errore del compilatore:
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at jaja.main(jaja.java:105)
un grazie a tutti:cry: