ERROR SENDING EMAIL: mailhost ?!

Joined
Mar 12, 2007
Messages
1
Reaction score
0
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

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);
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

2eoe06o.jpg


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" );
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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top