Results 1 to 2 of 2
  1. #1
    npoorni is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default Problem in sending mail from java

    i am getting the below exception while sending mail from a java application. what could be reason and how to solve this error.

    javax.mail.MessagingException: Exception reading response;
    nested exception is: Connection reset

    The code is:

    Java Code:
    public void postMail(String hostName, String recipients[], String subject,
    			String message, String from) throws MessagingException {
    		boolean debug = false;
    		// Set the host smtp address
    		Properties props = new Properties();
    		props.put("", hostName);
    		Session session = Session.getDefaultInstance(props, null);
    		Message msg = new MimeMessage(session);
    		// set the from and to address
    		InternetAddress addressFrom = new InternetAddress(from);
    		InternetAddress[] addressTo = new InternetAddress[recipients.length];
    		for (int i = 0; i < recipients.length; i++) {
    			addressTo[i] = new InternetAddress(recipients[i]);
    		msg.setRecipients(Message.RecipientType.TO, addressTo);
    		msg.setContent(message, "text/plain");

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Cambridge, UK
    Rep Power


    Your connection is being closed by the server. Check any authentication that might be necessary, or any possible network problems.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

Similar Threads

  1. Java Mail sending
    By jazz2k8 in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2011, 06:08 AM
  2. Facing problem while sending e-mail
    By jay8186 in forum Java Servlet
    Replies: 1
    Last Post: 03-25-2009, 08:34 AM
  3. Sending a Mail
    By haiforhussain in forum Advanced Java
    Replies: 7
    Last Post: 07-30-2008, 12:28 AM
  4. Sending Mail Using Sockets
    By Java Tip in forum
    Replies: 0
    Last Post: 04-07-2008, 08:05 PM
  5. Sending a mail with the local mail program
    By thedude in forum Advanced Java
    Replies: 2
    Last Post: 07-23-2007, 12:19 PM

Posting Permissions

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