-
send email
i'm new in java
please help me i wont send Email but i can'd
i using by package SMTP with smtp.jar and i get error when i send email:
netscape.security.AppletSecurityException:
security.Couldn't connect to 'mailhost' with origin from 'local- classpath-classes'.
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code) at java.lang.RuntimeException.<init>(Compiled
Code)
at java.lang.SecurityException.<init>(Compiled
Code)
at netscape.security.AppletSecurityException.<init>(Compiled Code)
at netscape.security.AppletSecurityException.<init>(Compiled Code)
at netscape.security.AppletSecurity.checkConnect(Compiled Code)
at java.lang.SecurityManager.checkConnect(Compiled Code)
at java.net.InetAddress.getAllByName0(Compiled Code) at
java.net.InetAddress.getByName(Compiled Code)
at java.net.Socket.<init>(Compiled Code) at sun.net.NetworkClient.doConnect(Compiled
Code)
at sun.net.NetworkClient.openServer(Compiled Code) at sun.net.smtp.SmtpClient.openServer(Compiled
Code)
at sun.net.smtp.SmtpClient.<init>(Compiled Code) at sun.net.smtp.SmtpClient.<init>(Compiled
Code)*
at sendEMail.send(Compiled Code)
at forgot.actionPerformed (Compiled Code)
at java.awt.Button.processActionEvent(Compiled Code) at java.awt.Button.processEvent(Compiled
Code)
at java.awt.Component.dispatchEventImpl(Compiled Code)
at java.awt.Component.dispatchEvent(Compiled Code) at java.awt.EventDispatchThread$EventPump.dispatchEvents
(Compiled Code)
at java.awt.EventDispatchThread.run(Compiled Code) at
netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run (Compiled
Code)
this is code i use
public void send(String from, String to, String subject, String message)
{
try
{
System.out.println( "*** sendEMail : new SmtpClient");
SmtpClient client = new SmtpClient("localhost");
System.out.println( "*** sendEMail : client = " +
client.getMailHost());
// domains in both from and to must be valid!
client.from( from );
System.out.println( "*** sendEMail : client.from( from )");
client.to( to );
System.out.println( "*** sendEMail : client.to( to )");
PrintStream ps =
client.startMessage();
System.out.println( "*** sendEMail : client.startMessage ()");
//ps.println("Subject: " + subject);
//blank line between subject and message
ps.println();
System.out.println( "*** sendEMail : ps.println()");
ps.println(message );
System.out.println( "*** sendEMail : ps.println (message )");
client.closeServer();
System.out.println( "*** sendEMail : Sending sucssesful!");
}
catch( IOException ex )
{
System.out.println( "--- sendEMail : Sending failed: " +
ex.getMessage() );
}
thanks for advance.
-
Re: send email
Are you using the word 'mailhost' or are you using the actual name of an
SMTP server? First of all, you have to provide the name of an actual SMTP
server that will send the mail for you, and second, you have to follow the
applet security rules for accessing that server (which I can't explain to
you because I don't know what they are).
PC2
marina <marina.gozman@elex.co.il> wrote in message
news:3aace777$1@news.devx.com...
>
> i'm new in java
> please help me i wont send Email but i can'd
> i using by package SMTP with smtp.jar and i get error when i send email:
>
> netscape.security.AppletSecurityException:
> security.Couldn't connect to 'mailhost' with origin from 'local-
classpath-classes'.
>
> at java.lang.Throwable.<init>(Compiled Code)
> at java.lang.Exception.<init>(Compiled Code) at
java.lang.RuntimeException.<init>(Compiled
> Code)