Hi,
I see, looks very simple, didnt knew of this possibility to send
e-mails.
What's still unclear to me is:
- if, where and how the SMTP server address is specified.
- The need to use of to_address in both URL "mailto:mom@athome"
and in a header line: "To: mom@home"
Listing content of rt.jar found package(s):
sun/net/www/protocol/{file,http,doc,ftp,mailto,systemresource}/Xxxx.class
Does anybody knows if these specific URL protocol classes are documented
somewhere - (e.g. what "doc" and "systemresource" are good for?)
Or they-re also non-standard, unsupported as sun.net.smtp package?
Thanks,
Cezar.
On Thu, 17 Jun 1999, Carlos Amengual wrote:
> Cezar Totth wrote:
> >
> > Hi,
> >
> > I knew "mailto:" URLs are available only from within browsers (and perhaps
> > their included JVM, or applets), but not from any JVM.
>
> It is not a browser-only thing. Don't confuse it with "mailto:" URLs
> embedded in Web pages. I've been using it with servlets in the meantime
> between jdk1.1 and Javamail availability. Now I use Javamail.
>
> > How should I use such an URL to send e-mails from a servlet?
>
> A slightly modified cut & paste from a very simple convenience method I
> have:
>
> try
> {
> URL u = new URL("mailto:"+ to_address);
> URLConnection c = u.openConnection();
> c.setDoInput(false);
> c.setDoOutput(true);
> c.connect();
> PrintWriter out = new PrintWriter(
> new PrintWriter(new OutputStreamWriter(c.getOutputStream())));
> out.println(this.toString());
> out.println();
> out.close();
> }
> catch(Exception e)
> {
> // Your exception handling here...
> }
>
> where "this.toString()" essentially contains something like:
>
> return new StringBuffer()
> .append("From: ")
> .append(from_address)
> .append("\n")
> .append("To: ")
> .append(to_address)
> .append("\n")
> .append("Subject: ")
> .append(subject)
> .append("\n")
> .append(body)
> .toString();
>
>
> This isn't my exact code as I have omitted a hack to send messages to
> multiple recipients, but otherwise the above code has run reliably to
> me.
>
>
> Carlos
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html