Results 1 to 3 of 3

Thread: javax.mail

  1. #1
    sashaxiv is offline Member
    Join Date
    Feb 2011
    Location
    Spain
    Posts
    26
    Rep Power
    0

    Default javax.mail

    Hi all.
    I have a problem related with javax.mail and an exchange server.

    Once the program gets the line of Transport.send(message), i have no response nor exception.

    I've also checked with tcpview for Win that the connection with the server is established. This is my code:

    Java Code:
    public class MailExample {
    	
    	
    	public static void main(String[] args) throws MessagingException {
    		new MailExample().run();
    	}
    
    	private void run() throws MessagingException {
    		Message message = new MimeMessage(getSession());
    
    		message.addRecipient(RecipientType.TO, new InternetAddress("xxxx@xxxx.com"));
    		message.addFrom(new InternetAddress[] { new InternetAddress("xxxx@xxxx.com") });
    
    		message.setSubject("the subject");
    		message.setContent("the body", "text/plain");
    
    		Transport.send(message);
    		System.out.println ("Mensaje enviado con éxito");
    	}
    
    	private Session getSession() {
    		Authenticator authenticator = new Authenticator();
    
    		Properties properties = new Properties();
    		properties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName());
    		properties.setProperty("mail.smtp.auth", "true");
    
    		properties.setProperty("mail.smtp.host", "xxxxxxx.central.xxxxxx.xxxxxx");
    		properties.setProperty("mail.smtp.port", "7190");
    		properties.setProperty("mail.smtp.user", "xxxxxx");
    
    		return Session.getInstance(properties, authenticator);
    	}
    
    	private class Authenticator extends javax.mail.Authenticator {
    		private PasswordAuthentication authentication;
    
    		public Authenticator() {
    			String username = "CENTRAL\\xxxxxxxx";
    			String password = "xxxxxxx";
    			authentication = new PasswordAuthentication(username, password);
    		}
    
    		protected PasswordAuthentication getPasswordAuthentication() {
    			return authentication;
    		}
    	}
    }

    Any ideas?
    Thanks in advance!

  2. #2
    sashaxiv is offline Member
    Join Date
    Feb 2011
    Location
    Spain
    Posts
    26
    Rep Power
    0

    Default

    the problem was in the server side.

    Now the program is running.

  3. #3
    jjmb is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default

    Hello I have a similar issue, however, I do get a bit further. When I call transport.send() I get the following exception "javax.mail.AuthenticationFailedException: failed to connect, no password specified?" I have specified a user and password. I see the same as part of the debug output, which is enabled via session.setDebug(true) and mail.debug=true in the properties file. I have tried many gyrations to transmit mail with no success.

    Thanks,

    John

Similar Threads

  1. javax.mail Query HELP
    By ravjot28 in forum Networking
    Replies: 2
    Last Post: 01-22-2010, 01:16 PM
  2. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 05:37 AM
  3. javax.mail.Transport
    By sharpi03 in forum Advanced Java
    Replies: 5
    Last Post: 10-23-2009, 05:26 PM
  4. Replies: 2
    Last Post: 05-05-2008, 06:01 AM
  5. I can't import javax.mail
    By katie in forum New To Java
    Replies: 2
    Last Post: 08-04-2007, 05:05 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
  •