Results 1 to 1 of 1
Thread: Java Mail Issue
- 10-19-2012, 08:20 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
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
The Error I am gettingJava Code:import java.io.IOException; import java.io.InputStream; 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/PROPERTIES.properties"); prop.load(is); } 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("mail.smtp.host", SMTP_HOST_NAME); props.put("mail.smtp.port", SMTP_PORT); props.put("mail.smtp.socketFactory.port", "26"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); Authenticator auth = new SMTPAuthenticator(); Session session = Session.getDefaultInstance(props, auth); session.setDebug(debug); // create a message Message msg = new MimeMessage(session); // set the from and to address InternetAddress addressFrom = new InternetAddress(SMTP_EMAIL); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[1]; addressTo[0] = new InternetAddress(recipient); msg.setRecipients(Message.RecipientType.TO, addressTo); // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/plain"); Transport.send(msg); } /** * 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); } }
Java Code:javax.mail.MessagingException: Could not connect to SMTP host: mail.something.com, port: 26; nested exception is: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638) at javax.mail.Service.connect(Service.java:317) at javax.mail.Service.connect(Service.java:176) at javax.mail.Service.connect(Service.java:125) at javax.mail.Transport.send0(Transport.java:194) at javax.mail.Transport.send(Transport.java:124)
Information I was given for the server:
server name for both incoming and outgoing email: mail.somethin.com
username: someone@something.com
Password: *******
Outgoing port 26
Incoming port POP3 110
Thanks for helping me. Hopefully I am not crazyLast edited by rdcian; 10-19-2012 at 08:22 AM.
Similar Threads
-
trying to sendin mail with java mail api
By akhilsrivastava in forum Advanced JavaReplies: 1Last Post: 04-04-2012, 09:34 PM -
send mail via java without java mail API
By majidvadoostan in forum NetworkingReplies: 2Last Post: 04-26-2011, 09:30 PM -
How to identify received mail is failure delivery notice mail in javamail?
By satheeshtech in forum Advanced JavaReplies: 2Last Post: 07-25-2009, 09:36 AM -
Attachments were missing when mail was sent through java mail API
By Malathi in forum Web FrameworksReplies: 2Last Post: 06-04-2009, 01:42 PM -
Javax.mail.MethodNotSupported Exception in java mail api
By namarc in forum Advanced JavaReplies: 2Last Post: 05-05-2008, 06:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks