Results 1 to 1 of 1

Thread: Java Mail Issue

  1. #1
    rdcian is offline Member
    Join Date
    Oct 2012
    Rep Power

    Question Java Mail Issue

    I have read many posts from many people and haven't been able to figure out what is going on.

    My problem is shown below, why am I getting this error message?

    The code I am using
    Java Code:
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class Email {
        private String SMTP_HOST_NAME;
        private String SMTP_EMAIL;
        private String SMTP_USER;
        private String SMTP_PWD, SMTP_PORT;
        public Email(){
            Properties prop = new Properties();
            try {
                InputStream is = getClass().getResourceAsStream("manage/");
            } catch (IOException ex) {
            SMTP_HOST_NAME = prop.getProperty("SMTP.HOST.NAME");
            SMTP_USER = prop.getProperty("SMTP.EMAIL.USER");
            SMTP_PWD = prop.getProperty("SMTP.EMAIL.PASSWORD");
            SMTP_EMAIL = prop.getProperty("SMTP.EMAIL");
            SMTP_PORT = prop.getProperty("SMTP.PORT");
        public void postMail(String recipient, String subject,
                String message) throws MessagingException {
            boolean debug = false;
            //Set the host smtp address
            Properties props = System.getProperties();
            props.put("mail.smtp.auth", "true");
            props.put("mail.smtp.starttls.enable", "true");
            props.put("", SMTP_HOST_NAME);
            props.put("mail.smtp.port", SMTP_PORT);
            props.put("mail.smtp.socketFactory.port", "26");
            Authenticator auth = new SMTPAuthenticator();
            Session session = Session.getDefaultInstance(props, auth);
            // create a message
            Message msg = new MimeMessage(session);
            // set the from and to address
            InternetAddress addressFrom = new InternetAddress(SMTP_EMAIL);
            InternetAddress[] addressTo = new InternetAddress[1];
            addressTo[0] = new InternetAddress(recipient);
            msg.setRecipients(Message.RecipientType.TO, addressTo);
            // Setting the Subject and Content Type
            msg.setContent(message, "text/plain");
         * SimpleAuthenticator is used to do simple authentication
         * when the SMTP server requires it.
        private class SMTPAuthenticator extends javax.mail.Authenticator {
            public PasswordAuthentication getPasswordAuthentication() {
                String username = SMTP_USER;
                String password = SMTP_PWD;
                return new PasswordAuthentication(username, password);
    The Error I am getting

    Java Code:
    javax.mail.MessagingException: Could not connect to SMTP host:, port: 26;
      nested exception is: Unrecognized SSL message, plaintext connection?
    	at com.sun.mail.smtp.SMTPTransport.openServer(
    	at com.sun.mail.smtp.SMTPTransport.protocolConnect(
    	at javax.mail.Service.connect(
    	at javax.mail.Service.connect(
    	at javax.mail.Service.connect(
    	at javax.mail.Transport.send0(
    	at javax.mail.Transport.send(

    Information I was given for the server:

    server name for both incoming and outgoing email:
    Password: *******
    Outgoing port 26
    Incoming port POP3 110

    Thanks for helping me. Hopefully I am not crazy
    Last edited by rdcian; 10-19-2012 at 08:22 AM.

Similar Threads

  1. trying to sendin mail with java mail api
    By akhilsrivastava in forum Advanced Java
    Replies: 1
    Last Post: 04-04-2012, 09:34 PM
  2. send mail via java without java mail API
    By majidvadoostan in forum Networking
    Replies: 2
    Last Post: 04-26-2011, 09:30 PM
  3. Replies: 2
    Last Post: 07-25-2009, 09:36 AM
  4. Replies: 2
    Last Post: 06-04-2009, 01:42 PM
  5. Replies: 2
    Last Post: 05-05-2008, 06:01 AM

Posting Permissions

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