webax Posted July 20, 2009 Posted July 20, 2009 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
Valentin Posted July 20, 2009 Posted July 20, 2009 Looks like your smtpHost parameter is set to "your_smtp_server.com" replace the value for that parameter with the IP address.
webax Posted July 22, 2009 Author Posted July 22, 2009 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;
Valentin Posted July 22, 2009 Posted July 22, 2009 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?
Recommended Posts
This topic is 5614 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now