Hi everyone,
I have a little problem with my java mail coding.
While i was using java mail coding in local netwok(intranet) properly executing.
But i was used in internet, it is not working.
I told my problem(java mail is not working prperly) to my server maintainer(service provider).
They told "we loaded all mandatory jar files in Tomcat server please verify your coding"
And told " please check your smtp protocal" and wrote code
u shoud use smtp as 25
other things asp and php coding are not supported in java server ..
u should send mail coding through jsp
Please check once & let us know if any problems !
Please let us know the error URL / Path if you have any more problems, thanks
please refer my coding and tell what is wrong with coding
[COLOR=darkred]Properties props = System.getProperties();[/COLOR] [COLOR=darkred]props.put("mail.smtp.host", host);[/COLOR] [COLOR=darkred]//props.put("mail.debug", "true");[/COLOR] [COLOR=darkred]Session session = Session.getInstance(props, null);[/COLOR] [COLOR=darkred]//session.setDebug(debug);[/COLOR] [COLOR=darkred]try {[/COLOR] [COLOR=darkred]// create a message[/COLOR] [COLOR=darkred]MimeMessage msg = new MimeMessage(session);[/COLOR] [COLOR=darkred]msg.setFrom(new InternetAddress(from));[/COLOR] [COLOR=darkred]InternetAddress[] address = {new InternetAddress(to)};[/COLOR] [COLOR=darkred]msg.setRecipients(Message.RecipientType.TO, address);[/COLOR] [COLOR=darkred]msg.setSubject(subject);[/COLOR] [COLOR=darkred]// create and fill the first message part[/COLOR] [COLOR=darkred]MimeBodyPart mbp1 = new MimeBodyPart();[/COLOR] [COLOR=darkred]mbp1.setText(msgText1);[/COLOR] [COLOR=darkred]// create the second message part[/COLOR] [COLOR=darkred]MimeBodyPart mbp2 = new MimeBodyPart();[/COLOR] [COLOR=darkred]// attach the file to the message[/COLOR] [COLOR=darkred]FileDataSource fds = new FileDataSource(filename);[/COLOR] [COLOR=darkred]mbp2.setDataHandler(new DataHandler(fds));[/COLOR] [COLOR=darkred]mbp2.setFileName(fds.getName());[/COLOR] [COLOR=darkred]// create the Multipart and add its parts to it[/COLOR] [COLOR=darkred]Multipart mp = new MimeMultipart();[/COLOR] [COLOR=darkred]mp.addBodyPart(mbp1);[/COLOR] [COLOR=darkred]mp.addBodyPart(mbp2);[/COLOR] [COLOR=darkred]// add the Multipart to the message[/COLOR] [COLOR=darkred]msg.setContent(mp);[/COLOR] [COLOR=darkred]// set the Date: header[/COLOR] [COLOR=darkred]msg.setSentDate(new java.util.Date());[/COLOR] [COLOR=darkred]// send the message[/COLOR] [COLOR=darkred]Transport.send(msg);[/COLOR] [COLOR=darkred]flag=true;[/COLOR] [COLOR=darkred]}catch (MessagingException mex) {[/COLOR] [COLOR=darkred]// Prints all nested (chained) exceptions as well[/COLOR] [COLOR=darkred]mex.printStackTrace();[/COLOR] [COLOR=darkred]}[/COLOR]
please reply immediately
thanks
sundar