email issue with spring and java mail api -
my application running in websphere 6.1 in aix box, in there email notification module works fine till today. same application getting migrated tomcat based cloud platform running in linux server. emails getting sent out new linux based platform intended recipients, email looking weird no subject, no recipient email address, attachments not proper, etc.
previously ant-based build , build project maven. , tried maintain same versions of spring , mail service api jars.
what issue , doing wrong here? there no exceptions while sending email , hard identify issue. appreciate help , in advance.
code:
public synchronized void sendwithattachment(mailmessage mailmessage) throws mailexception, messagingexception { string methodname = "sendwithattachment"; logmanager.info(logconstants.notification, constants.entering_method + methodname, this.getclass()); try{ mailsender mailsender = (mailsender) mailsender; session session = mailsender.getsession(); mimemessagehelper message = new mimemessagehelper(new mimemessage(session), true, "utf-8"); message.setfrom(mailmessage.getfrom()); message.setto(mailmessage.getto()); message.setsubject(mailmessage.getsubject()); message.setsentdate(new date()); message.settext(mailmessage.gettext()); diskfileattacher[] diskfileattachments = mailmessage.getdiskfileattachments(); (int = 0; ((diskfileattachments != null) && < diskfileattachments.length); i++) { message.addattachment(diskfileattachments[i].getattachmentfilename(), new file(diskfileattachments[i].getfilepath())); } inmemoryfileattacher[] inmemoryfileattachments = mailmessage.getinmemoryfileattachments(); (int = 0; ((inmemoryfileattachments != null) && < inmemoryfileattachments.length); i++) { if(inmemoryfileattachments[i].getfileobj()!=null){ message.addattachment(inmemoryfileattachments[i].getfilename(), inmemoryfileattachments[i].getfileobj() ); }else{ message.addattachment(inmemoryfileattachments[i].getfilename(), inmemoryfileattachments[i]); } } list mimemessagelist = new arraylist(); mimemessagelist.add(message.getmimemessage()); mimemessage[] mimemessages = (mimemessage[]) mimemessagelist.toarray(new mimemessage[mimemessagelist.size()]); logmanager.info(logconstants.notification,"before mailsender.send called " + methodname, this.getclass()); mailsender.send(mimemessages); }catch(mailexception e){ logmanager.info(logconstants.notification, "some exception occured while sending emails...", this.getclass()); }
check version of javamail you're using. if you're including javamail jar file in application, there may re-create of gnu version of javamail on linux scheme that's beingness used instead of yours. libgnumail-java package.
spring email smtp javamail email-attachments
No comments:
Post a Comment