dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: send emails using smtp

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    32

    Cool send emails using smtp

    i used the following code for sending a mail.

    <%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>

    <%
    String from="fromaddr";
    String to="toaddr";
    try{
    SmtpClient client = new SmtpClient("server");
    client.from(from);
    client.to(to);
    out.println("client");
    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();
    message.println("Cool beans! :-)");
    message.println();
    message.println();
    client.closeServer();
    }
    catch (IOException e){
    out.println("ERROR SENDING EMAIL:"+e);
    }
    %>


    for the server i dont know what to give. It says:
    ERROR SENDING EMAIL:sun.net.smtp.SmtpProtocolException: 550 5.7.1 Unable to relay for toaddr.

    for toaddr i given a valid address and also from adr i given a valid address.

    just help me out.

  2. #2
    Join Date
    Jan 2007
    Posts
    32
    The problem was with the server. I gave the correct server name. It works with correctly with the above code......

  3. #3
    Join Date
    Oct 2004
    Location
    The very depths of programming hell
    Posts
    828
    Cool beans indeed

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles