# Sendmail relaying denied 550 5.7.1 problem



## mdudley (Mar 3, 2017)

I have a server that has a half dozen domains associated with it.  Until now I have used LOCK-NET.COM for the nameserver for both dns http and email mx and never had any problems with email.  I just added a domain which is registered by godaddy and am using their nameserver for it instead of LOCAL-NET.COM.  When I try to send emails to the new domain, I get the relaying denied error.  I can send emails to the same users on all the other domains other than the new one fine, so I am pretty sure it is a problem with the mx record, but I cannot find what might be the cause.  Here are log file entries:

When sending to the new domain septicchecker.com I get this:

```
Mar  3 13:56:10 king-cart sm-mta[65899]: v23IuA2N065899: ruleset=check_rcpt, arg1=<sccontact@septicchecker.com>, relay=s2.neomailbox.net [5.148.176.60], reject=550 5.7.1 <sccontact@septicchecker.com>... Relaying denied
Mar  3 13:56:11 king-cart sm-mta[65899]: v23IuA2N065899: from=<mdudley@king-cart.com>, size=1650, class=0, nrcpts=0, proto=ESMTP, daemon=IPv4, relay=s2.neomailbox.net [5.148.176.60]
```
If I send to the same user on any other domain on the server it works fine, with this log entry:

```
Mar  3 14:30:07 king-cart sm-mta[7568]: v23JU6gW007568: from=<mdudley@king-cart.com>, size=307, class=0, nrcpts=1, msgid=<58B9C43A.4060102@king-cart.com>, proto=ESMTP, daemon=IPv4, relay=s2.neomailbox.net [5.148.176.60]
Mar  3 14:30:07 king-cart sm-mta[7569]: v23JU6gW007568: to=<sccontact@byterunner.com>, ctladdr=<mdudley@king-cart.com> (1006/1006), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30582, relay=local, dsn=2.0.0, stat=Sent
```
I have been looking for a solution on the net for the last 3 days but cannot find anything which seems applicable here.

Any assistance or hints would be greatly appreciated.


----------



## drhowarddrfine (Mar 3, 2017)

Relaying of email is something you often don't want because spammers will use it to relay their own mail. Therefore, sendmail has this turned off by default.


----------



## usdmatt (Mar 3, 2017)

Your mail server is not configured correctly to accept email for the septicchecker.com domain. It's giving relay denied because Sendmail will not accept email from remote hosts for non-local domains by default.

Make sure the domain you want to accept email for is in /etc/mail/local-host-names


----------



## mdudley (Mar 5, 2017)

I am not relaying, just trying to receive emails on the server.

I did not have any local-host-names file at all in the /etc/mail directory.  So I created one and put septicchecker.com and www.septicchecker.com in it.  I still have exactly the same problem with exactly the same entries in the log file when I try to send emails to that domain.

I have no configuration in mail server for any of the other domains and they receive fine.  For instance I can grep for both the domain names and the ip's in /etc/mail, and it comes up with no matches (except for the one I just added to the newly created local-host-names file of course).

Thanks,

Marshall


----------



## usdmatt (Mar 5, 2017)

> I am not relaying, just trying to receive emails on the server.


Yes I realize that, but clearly your mail server doesn't as it is trying to relay the emails rather than deliver them locally.



> I did not have any local-host-names file at all in the /etc/mail directory. So I created one and put septicchecker.com and www.septicchecker.com in it. I still have exactly the same problem with exactly the same entries in the log file when I try to send emails to that domain.
> 
> I have no configuration in mail server for any of the other domains and they receive fine. For instance I can grep for both the domain names and the ip's in /etc/mail, and it comes up with no matches (except for the one I just added to the newly created local-host-names file of course).



Is this a default Sendmail config or has somebody changed it? I've used Sendmail professionally for over 10 years and it just doesn't work like that. Sendmail will not just accept emails for random domains, you have to tell it which domains it should treat as local. There are a couple of ways of doing that, although the standard and easiest method is with local-host-names. (It might be that you have the domains listed in /etc/hosts although I wouldn't do it that way).

This is how you would normally configure Sendmail on a new system -


```
# cd /etc/mail
# make
```
This will create /etc/mail/hostname.mc which is where you'd configure Sendmail itself. Sendmail works fine without changing anything in this file but this is where you'd change timeouts, enable SSL, add a smart host, etc, etc. When you run `make` it also compiles this file into hostname.cf.


```
# make install
```
This basically just installs hostname.cf as sendmail.cf. You can also run `make restart` to restart the Sendmail service.

At this point Sendmail will only really accept email for system-user@local-hostname. To accept other domains or email addresses, you would do something like the following:

/etc/mail/local-host-names

```
domain1.com
domain2.com
```
These are the additional domains you want Sendmail to treat as local and accept email for. You do not need to add www.domain1.com to this unless you actually want to accept system-user@www.domain1.com.

/etc/mail/virtusertable

```
@domain1.com    error:550 user unknown
info@domain1.com   system-user
```
You don't really need a virtusertable if you're just using system-user@domain1.com, however it's used if you want to use addresses where the prefix isn't a real user. For example, above I've got an info@domain1.com address, which will be delivered to system-user. I also usually add an explicit reject for the 'catch-all', so that only the addresses I specifically want to use are accepted. This stops messages for bob@some-domain being accepted just because I happen to have a bob user.

Bear in mind you need to restart Sendmail after changing the configuration files, and virtusertable needs to be made into a database file by running `make`.

You can test configuration using `sendmail -bv address`:

```
# sendmail -bv info@gmail.com
info@gmail.com... deliverable: mailer esmtp, host gmail.com., user info@gmail.com
```
This address will be delivered externally via smtp, to the mail servers responsible for gmail.com. By default Sendmail will only deliver external email received from localhost, or a client you have enabled relaying for (or an authenticated client). Otherwise you'll get a 'relaying denied' error - You don't want to allow random hosts on the net to send email to your server and have your server relay it back out to an external recipient.


```
# sendmail -bv sales@mydomain.com
sales@mydomain.com... deliverable: mailer local, user karen
```
This is what you should see if you've correctly configured Sendmail to accept email for a domain. In this case the address is local so Sendmail will accept inbound email from anywhere, and it will be delivered to the karen system user.


----------

