Hi all,
Thats my 1st post on this very helpful forum; glad to be with you all
I'm using Sun Java Studio Creator-2 IDE
and I'm trying to send mail from my web application
using this code
I get this message in the system error message :
ERROR SENDING EMAIL: mailhost
I'm sure that the problem is in this line
as I tried to debug the project with a breakpoint on the above line
and the results of local variables is shown on this screen shot
It seems from debugging session shown above that there is a "mailhost" string that is thrown before the SMTP server name causing this exception
after googling this issue, I found a similar issue posted on this forum
http://www.velocityreviews.com/forums/t133447-urlmailto-approach.html
that had been solved by adding this line before sending the mail
which is supposed to configure the system property
but for sorrow nothing changed with my issue & the same exception occurs
Please kindly advise or direct me to any helpful link or topic; as I'm stucked in this issue for weeks :-(
Thanks in advance
Thats my 1st post on this very helpful forum; glad to be with you all
I'm using Sun Java Studio Creator-2 IDE
and I'm trying to send mail from my web application
using this code
Code:
public String sendMail_action()
{
String from = "*******@yahoo.com"; // from address
String to = "******@myComponey.com"; // to address
String mailserver = "*****.**.***.myComponey.com";
String fullName = candidateFullNameDataProvider.getValue("candidate.f_name").toString() + " "+ candidateFullNameDataProvider.getValue("candidate.l_name").toString();
try
{
sun.net.smtp.SmtpClient client = new sun.net.smtp.SmtpClient(mailserver);
info("mail sent");
client.from(from);
client.to(to);
java.io.PrintStream message = client.startMessage();
message.println("To: " + to);
// TODO: set the subject line
message.println("Subject: Candidate "+fullName+" Status update");
// TODO: set the body of the message
message.println("Candidate "+ fullName +" is forwarded to SPOC for testing");
client.closeServer();
}
catch (java.io.IOException ex)
{
// in the case of an exception, print a message to the output log
log("ERROR SENDING EMAIL:"+ex);
error("ERROR SENDING EMAIL: " + ex.getMessage());
}
return null;
}
I get this message in the system error message :
ERROR SENDING EMAIL: mailhost
I'm sure that the problem is in this line
Code:
sun.net.smtp.SmtpClient client = new sun.net.smtp.SmtpClient(mailserver);
and the results of local variables is shown on this screen shot
It seems from debugging session shown above that there is a "mailhost" string that is thrown before the SMTP server name causing this exception
after googling this issue, I found a similar issue posted on this forum
http://www.velocityreviews.com/forums/t133447-urlmailto-approach.html
that had been solved by adding this line before sending the mail
Code:
System.setProperty("mail.host","*****.**.***.myComponey.com" );
but for sorrow nothing changed with my issue & the same exception occurs
Please kindly advise or direct me to any helpful link or topic; as I'm stucked in this issue for weeks :-(
Thanks in advance