Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Re: About sending mail without mail server...


Message #1 by "Vianneth Payan" <vpayan@p...> on Mon, 4 Mar 2002 15:18:45
no problem:

code nicked from zdnet developer
http://www.zdnet.com/devhead/stories/articles/0,4413,2775598,00.html

import javax.mail.*;
import javax.mail.internet.*;
javax.activation.*;
import java.util.*;

=A0try{
=A0=A0Properties props =3D new Properties();
=A0=A0Session sendMailSession;
=A0=A0Store store;
=A0=A0Transport transport;


=A0=A0sendMailSession =3D Session.getInstance(props, null);

=A0=A0props.put("mail.smtp.host", "localhost:25");
/* the first value is not a URL, its a system variable. dont change it. 
The
second is the name of the smtp host, which is probably on port 25 - you
might need to change this. If you are on an NT network (DHCP or 
otherwise)
you can substitute your computer name but note that your proxy might 
block
calls to port 25 so you might need to change your internet preferences 
to
bypass the proxy for local addresses */

=A0=A0Message newMessage =3D new MimeMessage(sendMailSession);
=A0=A0newMessage.setFrom(new 
InternetAddress(request.getParameter("from")));
=A0=A0newMessage.setRecipient(Message.RecipientType.TO, new
InternetAddress(request.getParameter("to")));
=A0=A0newMessage.setSubject(request.getParameter("subject"));
=A0=A0newMessage.setSentDate(new Date());
=A0=A0newMessage.setText(request.getParameter("text"));

=A0=A0transport =3D sendMailSession.getTransport("smtp");
=A0=A0transport.send(newMessage);
=A0=A0=A0}
=A0catch(MessagingException m)
=A0=A0{
=A0=A0out.println(m.toString());
=A0=A0}
-----Original Message-----
From: Stephen Sutherland [mailto:stephensutherland@y...]
Sent: 04 March 2002 17:10
To: Servlets
Subject: [servlets] Re: About sending mail without mail server...


cool that sounds like fun

but could you give the exact java syntax ? -- for
example which object is being created with
localhost:port_num as the parameter ?

sorry for asking for the details


stev


--- Chanoch Wiggers <ChanochW@w...> wrote:
> you can send on a localhost smtp server that you can
> have with IIS 5. You
> just need to access it by name: localhost:port_num
> and it will be fine.
>
> chanoch
>
> -----Original Message-----
> From: Stephen Sutherland
> [mailto:stephensutherland@y...]
> Sent: 04 March 2002 17:00
> To: Servlets
> Subject: [servlets] Re: About sending mail without
> mail server...
>
>
> it would be nice to specify the com object on IIS
> 5.0
> and pass the message to it. Have you tried that ?
>
> stev
> --- Vianneth Payan <vpayan@p...> wrote:
> > I use javaMail now, but i don't know how do I use
> > sending message without
> > define a mail.smtp.host.  Remember, I don't have
> > mail server (an specific
> > IP)in my IIS 5.0, it only has installed SMTP
> > service.
> >
> >
> > > have you looked at the javamail api
> > >
> > > you can download it separate from j2ee
> > >
> > > the package is called javax.mail
> > >
> > > --- Vianneth Payan <vpayan@p...> wrote:
> > > > Do you know some possibilities in Java to send
> > mail
> > > > without SMTP server
> > > > like ASP do it?
> > > >
> > > > the code ASP below:
> > > >
> > > > Set objMail =3D
> > Server.CreateObject("CDONTS.NewMail")
> > > > objMail.From =3D request.QueryString("from")
> > > > objMail.To =3D request.QueryString("to")
> > > > objMail.Subject =3D
> request.QueryString("subject")
> > > > objMail.Body =3D body
> > > > objMail.Send
> > > > Set objMail =3D Nothing
> > > >
> > > > *******
> > > >
> > > > that=B4s for IIS 5.0, How can I do it in Java?
> > without
> > > > mail server, only
> > > > SMTP service installed??
> > > >
> > > > thank you!
> > > $subst('Email.Unsub').
> > >
> > >
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Sports - Coverage of the 2002 Olympic
> Games
> > > http://sports.yahoo.com
> >
> $subst('Email.Unsub').
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - sign up for Fantasy Baseball
> http://sports.yahoo.com
>
> $subst('Email.Unsub').
>
$subst('Email.Unsub').


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - sign up for Fantasy Baseball
http://sports.yahoo.com

$subst('Email.Unsub').

  Return to Index