This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sending an email from jsp  RSS feed

 
Divyajot Ahluwalia
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
I am preparing a jsp application where a certain event triggers off an email to a few recipients.
I am using the oreillys MailMessage class.
The issue is that when i open an object- i need to specify an email servers address. a normal isp does not allow a different ip to log on and send emails. how do i over come this problem?
is there any generic way of specifying the host name??
Looking forward to your speedy response.
Regards,
Dj
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Divyajot Ahluwalia:
[...] i need to specify an email servers address. a normal isp does not allow a different ip to log on and send emails. how do i over come this problem?

Short of using your own ISP, you can't. In the unlikely event that you find another mailserver which will relay your mail, enjoy it for the ten minutes it will take the spammers to get wise to the fact. And in the even more unlikely event that you do find a way around this, keep it secret!
is there any generic way of specifying the host name??

Well, that's what servlet configuration parameters are for (see ServletConfig.getInitParameter()). You then configure the mail host in the servlet's deployment descriptor (WEB-INF/web.xml).
Alternatives which will no doubt be suggested to you are environment variables, system properties and Java properties files, but IMHO all of these are to be avoided in a well-behaved web application (although properties files can be appropriate if they are maintained by the application itself - be sure to make their location relative to the web-app root though).
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!