July 20, 200916 yr hello sorry, my english is bad ... I want to send an email without authentification, but without succes I have configured IIS and SMTP I use this code import javax.mail.*; import javax.mail.internet.*; Properties props = new Properties(); props.setProperty("mail.smtp.host", smtpHost); MimeMessage msg = new MimeMessage(Session.getDefaultInstance(props)); Multipart content = new MimeMultipart(); MimeBodyPart bodyPart = new MimeBodyPart(); bodyPart.setText(body); content.addBodyPart(bodyPart); msg.setContent(content); msg.setSubject(subject); msg.setFrom(new InternetAddress(from)); msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to)); Transport.send(msg); return true; my parameters are - from [email protected] - to : [email protected] - subject : Test - Body : MyTest - smtpHost : 192.168.4.1 this smtpHost works with outlook but Error : java.net.UnkwonHostException: your_smtp_server.com I forgot something ? thanks
July 20, 200916 yr Looks like your smtpHost parameter is set to "your_smtp_server.com" replace the value for that parameter with the IP address.
July 22, 200916 yr Author I'm sorry but I don't understand your reponse. I do what import javax.mail.*; import javax.mail.internet.*; Properties props = new Properties(); props.setProperty("mail.smtp.host", [color:orange]"192.168.4.1"); MimeMessage msg = new MimeMessage(Session.getDefaultInstance(props)); Multipart content = new MimeMultipart(); MimeBodyPart bodyPart = new MimeBodyPart(); bodyPart.setText(body); content.addBodyPart(bodyPart); msg.setContent([color:orange]"body"); msg.setSubject([color:orange]"subject"); msg.setFrom(new InternetAddress([color:orange][email protected])); msg.setRecipient(Message.RecipientType.TO, new InternetAddress([color:orange][email protected])); Transport.send(msg); return true;
July 22, 200916 yr ok, looks like in your last post you are now "hardcoding" the smpt server address. Is this working for you? What error are you getting?
Create an account or sign in to comment