Java email received from standalone class, but not when executed within a servlet -
using java, can send email toy standalone class (with hard-coded data) fine, , receive email within seconds.
when exact same code called in context of servlet, however, code executes without failure, but don't receive email.
how be? there special servlet environment? i'm running tomcat 6, jre 1.5.
here code (i have edited data):
public void sendemail(string asubject, string abody){ properties props = new properties(); props.put("mail.host", "smtp.blah.ca"); props.put("mail.from", "from-blah@blah.ca"); session session = session.getdefaultinstance(props, null /*no authenticator*/); system.out.println("jre" + system.getproperty("java.version")); system.out.println(session.getproperties()); mimemessage message = new mimemessage(session); try { message.addrecipient( message.recipienttype.to, new internetaddress("to-blah@blah.com") ); message.setsubject(asubject); message.settext(abody); transport.send(message); } catch (messagingexception ex){ system.err.println("cannot send email. " + ex); } }
edit: email recieved when content (email body) small. when content large, it's not recieved.
this not java-related @ all.
i tested large email normal email client. same behavior seen: email sent fine, i'm not receiving in timely manner, reason. (i haven't seen kind of behavior before, there is...)
Comments
Post a Comment