la release e un file .txt?
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpHost);
ok quindi devo mettere nelle prime righe questi import?
<%@ page import="java.util.*"%>
<%@ page import="javax.mail.*"%>
<%@ page import="javax.mail.internet.*"%>
<%@ page import="javax.activation.*"%>
poi cosė....
<%
String smtpHost = "0";
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpHost);
%>
al posto di host devo mettere il mio server?
al posto di mail.smtp.host
io ho provato a copiare quello che c'č sul sito della moka..
é giusto?
Come faccio a specificare l'indirizzo del destinatario?
<%
String smtpHost = "0";
Properties props = System.getProperties();
props.put("mail.xxx.host", smtpHost);
Session c = 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");
// Create the multi-part
Multipart multipart = new MimeMultipart();
// Create part one
BodyPart messageBodyPart = new MimeBodyPart();
// Fill the message
messageBodyPart.setText("Here's the file");
// Add the first part
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
// Add the second part
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send message
Transport.send(message);
%>
Ah ho capito devo creare delle variabili
Che cos'č smtpHost dopo l'indirizzo del smtp, come lo devo settare?
<%
String smtpHost = "0";
Properties props = System.getProperties();
props.put("mail.xxx.host", smtpHost);
Session c = Session.getDefaultInstance(props, null);
String from = "prova@";
String to = "userfra@...";
MimeMessage message = new MimeMessage(c);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello this is a mail message");
// Send message
Transport.send(message);
%>
message.addRecipient(Message.RecipientType.TO, new InternetAddress("nome.cognome@server.it"));
mi da questo errore:
javax.servlet.ServletException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host: 0;
nested exception is:
java.net.UnknownHostException: 0
forse cosė
props.put("mail.smtp.host", "mailserverdautilizzare");