• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6684
  • Last Modified:

JavaMail SMTP 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)

I've developed a JavaMail form processor for a project of mine, however I am hung up on one problem.

I am using Tomcat and I run it on my local machine to test sending an email.
I use authentication and specifically enter the username and password for the server.  It works with no problem

When I use the same program on the public WebServer I get the 553 error when I try to send to an email adddress outside the domain.
javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.SendFailedException: Invalid Addresses; nested exception is: javax.mail.SendFailedException: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)

The Webserver still uses the same authentication.  Even stranger is when I Install Outlook and send email from that same address there is no problem

Please help
What can I do?
  • 2
  • 2
1 Solution
is your authentication getting called?
LiveWire530Author Commented:
Well I assume it authenticates, I see no errors with DEBUG option at the console level.
Plus I am sending 2 messages and the first one is within the domain and is also authenticated.

Below is the code:

public class LsbSmtpAuthenticator extends Authenticator {
            public PasswordAuthentication getPasswordAuthentication() {
                  return new PasswordAuthentication("fromaddr@mydomain.com", "mypassword");

Properties props = System.getProperties();
          props.put("mail.smtp.host", "mail.mydomain.com");
          props.put("mail.smtp.auth", "true");
      Authenticator auth = new LsbSmtpAuthenticator();
      javax.mail.Session Msession = javax.mail.Session.getInstance(props, auth);

          MimeMessage automessage = new MimeMessage(Msession);
          automessage.setFrom(new InternetAddress("fromaddr@mydomain.com"));
          automessage.addRecipient(Message.RecipientType.TO, new InternetAddress("toaddr@otherdomain.com"));

      MimeBodyPart ahtml = new MimeBodyPart();
      MimeBodyPart atext = new MimeBodyPart();
      MimeMultipart amultipart = new MimeMultipart("alternative");
perhaps add some debug to your getPasswordAuthentication() method to see that it is being called.
Of get some log of the SMTP traffic.
See the information here:

From reading that, and your question, it seems that:
when mail originates from your local machine, it is relayed ok.
when mail originates from your public webserver it is not relayed.

Now, you don't say who hosts your public webserver, or who your isp is,
but I know that for myself, my ISP will ONLY relay email that originates
from IP addresses it controls.  If I want to send email from my webserver
I have to use a different smtp server, run by the people who host my

So, it could just be you need to use a different mail.smtp.host (and authentication) for your webserver.

LiveWire530Author Commented:
The mail server I was using needed to have the webserver's IP added to to it relay list
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now