Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: DEBUG SMTP: could not connect to host "host.domain.uk", port: 25, response: 421

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DEBUG SMTP: could not connect to host "host.domain.uk", port: 25, response: 421

    I am using the java mail libary to try and send a confirmation email at the end of my program to say that everything went ok.

    I am getting the error 'DEBUG SMTP: could not connect to host "host.domain.uk", port: 25, response: 421'

    Here's some code;

        private static void emaillog(){
            // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
            String to = "admin@domain";
            String from = "system@domain";
            // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
            String host = "smtp.domain.uk";
     
            // Create properties for the Session
            Properties props = new Properties();
     
            // If using static Transport.send(),
            // need to specify the mail server here
            props.put("mail.smtp.host", host);
            // To see what is going on behind the scene
            props.put("mail.debug", "true");
     
            // Get a session
            Session session = Session.getInstance(props);
     
            try {
                // Get a Transport object to send e-mail
                Transport bus = session.getTransport("smtp");
     
                // Connect only once here
                // Transport.send() disconnects after each send
                // Usually, no username and password is required for SMTP
                bus.connect();
                // bus.connect("smtp.domain.uk", "admin", emailPassword);
     
                // Instantiate a message
                Message msg = new MimeMessage(session);
     
                // Set message attributes
                msg.setFrom(new InternetAddress(from));
                InternetAddress[] address = {new InternetAddress(to)};
                msg.setRecipients(Message.RecipientType.TO, address);
                // Parse a comma-separated list of email addresses. Be strict.
                msg.setRecipients(Message.RecipientType.CC,
                                    InternetAddress.parse(to, true));
                // Parse comma/space-separated list. Cut some slack.
                msg.setRecipients(Message.RecipientType.BCC,
                                    InternetAddress.parse(to, false));
     
                msg.setSubject("Test E-Mail through Java");
                msg.setSentDate(new Date());
     
                // Set message content and send
                setTextContent(msg);
                msg.saveChanges();
                bus.sendMessage(msg, address);
     
                bus.close();
     
            }
            catch (MessagingException mex) {
                // Prints all nested (chained) exceptions as well
                mex.printStackTrace();
                // How to access nested exceptions
                while (mex.getNextException() != null) {
                    // Get next exception in chain
                    Exception ex = mex.getNextException();
                    ex.printStackTrace();
                    if (!(ex instanceof MessagingException)) break;
                    else mex = (MessagingException)ex;
                }
            }
        }

    I have a multifunction printer that emails successfully with these settings

    Reception Protocol : SMTP
    E-mail Reception Interval : On
    : 15minute(s)
    Max. Reception E-mail Size : 2 MB
    E-mail Storage in Server : Off


    SMTP

    To Top
    SMTP Server Name : smtp.domain.uk
    SMTP Port No. : 25
    SMTP Authentication : Off
    SMTP Auth. E-mail Address :
    SMTP Auth. Encryption : Auto Select


    POP before SMTP

    To Top
    POP before SMTP : Off
    POP E-mail Address :
    Timeout setting after POP Auth. : 300 milli-second


    POP3/IMAP4

    To Top
    POP3/IMAP4 Server Name :
    POP3/IMAP4 Encryption : Auto Select


    E-mail Communication Port

    To Top
    POP3 Reception Port No. : 110
    IMAP4 Reception Port No. : 143
    Last edited by aueddonline; August 21st, 2012 at 08:22 AM.


Similar Threads

  1. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  2. Get "Object Moved" error when using url.openConnection and .connect
    By rwhejny in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 20th, 2011, 04:35 PM
  3. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM
  4. Replies: 1
    Last Post: March 31st, 2010, 09:42 PM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM