how to code a function to send an email to a predetermine email address.
I developt a sample but i got som error message due to mailhost .
the error is showen in attached file.
can anyone say me how to solve this problem. i tried several mailhost, but it was useless.

the code i wrote is :
<%@ page import=",*" %>
String from="";
String to="";
SmtpClient client = new SmtpClient("");
PrintStream message = client.startMessage();
message.println("To: " + to);
message.println("Subject: Sending email from JSP!");
message.println("This was sent from a JSP page!");
message.println("Cool beans! :-)");
catch (IOException e){
System.out.println("ERROR SENDING EMAIL:"+e);

Relaying issues are the most common problem when trying to send E-mail with a website. You need to make sure the SmtpClient settings are appropriate. From your code sample, you are trying to make use of gmail's mail server, in which case you need to use the appopriate server name, port, method, and credentials.

According to

server: ''
port: 465
scheme: ssl
username: your gmail username (i.e., whatever at gmail dot com)
password: your gmail password

However, according to the JavaMail FAQ (
"The JavaMail APIs currently have no support for sending or receiving secure email."

So you cannot send mail via g-mail's smtp server. You will need another smtp server, either a mail server that you use that would allow such (like the one you get your own E-mail from, besides g-mail, if you have another). If there are none, then you cannot send e-mail, unless you can install an smtp client on the server you are hosting this website and configure it to send your mail.

~ mellamokb

commented: Nice info +7