Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending mails from Java application

3 views
Skip to first unread message

kpalania

unread,
Sep 7, 2000, 11:54:38 AM9/7/00
to
Hi,
I downloaded the javamail1.1.3 package and tried executing the
demo msgsend.java and msgsendsample.java applications. However,
i get some errors. I am able to compile but not execute. I
expect to see the "usage" when i pass no arguments but i do not
see it. Do i need to install JAF to be able to use javamail?
Is there something i am missing here. What do i need to send a
mail successfully? Please advise.
Thank you.

Eric Anderson

unread,
Sep 7, 2000, 3:34:36 PM9/7/00
to
Yes, JavaMail requires JAF.

In article <0000005b...@usw-ex0108-192.remarq.com>, kpalania

kpalania

unread,
Sep 7, 2000, 2:59:25 PM9/7/00
to
Thanks, Eric. Do i need anything else to be able to run my
program. Also, what value does the smtpHost variable take, in
the statement below:
transport.connect(smtpHost, "", "");

Thank you.

David Alex Lamb

unread,
Sep 7, 2000, 4:24:49 PM9/7/00
to
In article <0000009e...@usw-ex0108-192.remarq.com>,

kpalania <kpalania...@sun.partner.remarq.com.invalid> wrote:
>Thanks, Eric. Do i need anything else to be able to run my
>program.

JAF should be all you need. Last time I looked (1.0) the POP3 transport
protocol package was separate, but they may have integrated it by now.

> Also, what value does the smtpHost variable take, in
>the statement below:
>transport.connect(smtpHost, "", "");

You need to have a mail server host for your outgoing mail, typically a
hostname supplied by your ISP. If you run any other mail service on the same
machine you can probably figure out the hostname (I had to look at my Netscape
preferences since I'd forgotten the exact name).

If you are writing something that has to be portable, it's fairly
straightforward if you're just having people send bug reports to you: just
pick the hostname part of your usual mailbox address. If it has to work
everywhere, you probably need to supply a way for users to set the SMTP host.

--
"Yo' ideas need to be thinked befo' they are say'd" - Ian Lamb, age 3.5
http://www.cs.queensu.ca/~dalamb/

kpalania

unread,
Sep 11, 2000, 9:18:39 AM9/11/00
to
Thanks, David. I tried using the hostname part of my email
address for the SMTP hostname and this is the error that i am
encountering (UnknownHostException). Please advise.

DEBUG: not loading system providers in <java.home>/lib
DEBUG: not loading optional custom providers file: /META-
INF/javamail.providers
DEBUG: successfully loaded default providers

DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name:
{com.sun.mail.smtp.SMTPTransport=javax.mail.Provi
r[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
Microsystems, Inc], com.sun.mail.im
IMAPStore=javax.mail.Provider
[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems,
c]}
DEBUG: Providers Listed By Protocol: {imap=javax.mail.Provider
[STORE,imap,com.sun.mail.i
p.IMAPStore,Sun Microsystems, Inc], smtp=javax.mail.Provider
[TRANSPORT,smtp,com.sun.mail
mtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: not loading optional address map file: /META-
INF/javamail.address.map

DEBUG: getProvider() returning javax.mail.Provider
[TRANSPORT,smtp,com.sun.mail.smtp.SMTP
ansport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false

DEBUG: SMTPTransport trying to connect to host "company.com",
port 25


--Exception handling in msgsendsample.java
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host:
company.com;
nested exception is:
java.net.UnknownHostException: company.com
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at msgsendsample.main(msgsendsample.java, Compiled Code)

Exception in thread "main" java.lang.ClassCastException
at msgsendsample.main(msgsendsample.java, Compiled Code)

0 new messages