I was trying to send an email using javaMail API using my own smtp server to gmail/hotmail/etc..I put the following code to specify smtp server's settings

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", "my smtp host");
props.put("mail.smtp.port", "my smtp host's port");

Session session = Session.getInstance(props,
          new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password); //my smtp server's username and password

But when I run the program..I get the error saying cannot find domain in username or something like that.
I have the username like xyz@myDomain.com..could anyone please suggest it what the error is about?? ssl/tls is not required for this smtp server.

Edited by cool_zephyr

5 Years
Discussion Span
Last Post by cool_zephyr

We will probably need something better than "or something like that", but my first guess would be to check the configuration of your local mail server. Can you send mail through it using an other mail tool?


i tried on a different computer..and it's working now, but it's in the junk folder..i don't know what went wrong on the other computer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.