----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
A stub from an SMTP client servlet... this works just peachy on Solaris,
Linux, WinNT, ...
private BufferedReader reader;
...
public void sendMail(String host, int port, String fromAddr,
String toAddr...)
{
Socket s = null;
try
{
s = new Socket(host, port);
reader = new BufferedReader(
new InputStreamReader(
s.getInputStream()));
reply("220");
PrintStream ps = new PrintStream(s.getOutputStream());
ps.print("HELO " + host + "\r\n");
ps.flush();
reply("250");
ps.print("MAIL FROM: <" + fromAddr + ">\r\n");
ps.flush();
reply("250");
...
}
catch(Exception e)
{
...
}
finally
{
try
{
s.close();
}
...
}
private void reply(String expected)
throws IOException
{
String reply = reader.readLine();
if(reply.startsWith(expected) == false)
{
throw new IOException(
"Unexpected response from SMTP server: " + reply);
}
}
Ed Park wrote:
>
> ----------------------------------------------------------------
> BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
> WHEN YOU POST, include all relevant version numbers, log files,
> and configuration files. Don't make us guess your problem!!!
> ----------------------------------------------------------------
>
> Several people have indicated that it is possible to
> create socket connections from their servlets.
> Whenever I've tried I always get exceptions thrown.
> Would those people be kind enough to supply a small
> example illustrating how it worked for them?
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Archives and Other: <http://java.apache.org/main/mail.html>
> Problems?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]