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.
Thanks.

Recommended Answers

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?

Jump to Post

All 2 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.