• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Create e-mail via servlet

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm currently implementing a web application which creates certain documents (PDF and DOC) using a servlet and displays them in a browser.

Now mail functionality is to be added as follows: after the document has been created, it is sent to a particular address as an e-mail attachment.

What I want to achieve is that the servlet creates the mail as a mime message in a way that the browser automatedly opens Outlook after it has received the message from the servlet. Unfortunately, for security purposes it is impossible to send the mail directly from the servlet-containes, but the mail must be returned to the client first.

Anyone got any idea???

Thanks, Alex
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say JavaMail would do all the jobs of managing e-mail; see:

http://java.sun.com/products/javamail

But I'm not quite sure about "the browser automatedly [automatically] opens Outlook after it has received the message from the servlet". Firstly, what's to say that the client uses Outlook at all? Even if they don't (and what you meant to say was "opens the mail client" rather than "opens Outlook"), sending e-mail via SMTP and sending HTTP messages are two completely different things - they don't really overlap. As a result, you can't send an e-mail from a servlet via HTTP to the client's browser. You can however send an e-mail via SMTP (a separate process) to the client, and you can achieve this using some servlet (or any Java) code - but that's a different thing altogether.

If you need clarification, please ask away...
[ March 17, 2006: Message edited by: Charles Lyons ]
 
Alexander D�ubler
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, thanks for the quick answer!

Yes, you're right, I meant 'open the default mail-client', of course... But on the other hand I'm quite sure that 99.99% of our customers are currently using Outlook as the default client. Well, be that as it may...

Could you please tell me more about sending the mail via SMTP to the browser? Is it thereby possible to open the default mail client?

Or is there any possibility to use JavaMail to send the mail directly from the server (instead of the client) to the receiver without getting into trouble with any security restrictions?


The main purpose of the mail functionality is as follows: the user that is currently logged on to the system creates a document, which is to be sent to the receiver of the document via e-mail. however, the document is not being created on the client machine but on the server. If the e-mail could somehow be sent to the client and automatedly opened in the default e-mail client then the user just needed to click on the send button and everything was fine. However, if the mail is being sent directly from the server authentication was needed, but there shouldn't be any commitment to the user to enter any password after logging on to the OS)...

I hope that made it a bit more clearer what our objectives are...


Thanks, Alex
[ March 17, 2006: Message edited by: Alexander D�ubler ]
 
Charles Lyons
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Could you please tell me more about sending the mail via SMTP to the browser? Is it thereby possible to open the default mail client?

E-mail isn't sent to the browser - it is sent to the user's e-mail inbox; they can then use a mail client to retrieve the messages from their inbox. The only way I know to get the mail client to open from the browser is when you use a hyperlink to open a new e-mail (using <a href="mailto:..."> , but that's a sending not receiving operation for the client.

Or is there any possibility to use JavaMail to send the mail directly from the server (instead of the client) to the receiver without getting into trouble with any security restrictions?



Absolutely - the point of JavaMail is to act as an interface for sending and receiving general e-mails. It wouldn't cause the mail client to open by default, but you could use an HTML message to alert the user that an e-mail has been sent to them, thereby prompting them to check for new mail. In order to send e-mails from JavaMail, all you need is an SMTP server (and the necessary permissions to use or relay from it) - you don't even have to be using J2EE to do this (there are many Java mail clients out there using JavaMail to send/receive e-mail from client machines)!

Depending on how confident you are with Java as a whole, and how much of the technical details of e-mail you know about, I would either recommend looking at the API and deducing things from that, or alternatively finding a tutorial on the Web - trying searching Google for "JavaMail tutorial" or similar. You might also want to check/ask in the Other Java APIs forum, since that covers JavaMail.

Good luck!
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The mail server you use for your personal mail may not be happy with handling mail from your servlet since it may look like spam from a mail zombie. The Apache "James" mail server in Java works for me.
Bill
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic