# Sendmail recieve problems



## danaeckel (Jul 29, 2012)

Hello all,
   I have a FreeBSD 9.0 configured as a multi-use server. I decided for fun and learning I would try to use the sendmail services that is offered, then when I get that going good I would add Dovecot and webmail services.
   I can send with sendmail quite well to services such as Yahoo and Gmail, and was easy to setup. However I am confused on how to configure it to recieve e-mail.
   This system is setup as a gate DNSMasq as well as IPFW running and two network cards. One card faces my local ISP, and the other faces my home network. I also have a subdomain from FreeDNS as well
   I have tried to e-mail direct to my public IP address as well as my FreeDNS name, and I get nothing.
   I have read about MX Records and all that, and that is when I get lost. I can't find a good example how to set it up with my type of setup, and I have no clue how to go about MX Records.

Could somebody toss some hints my way?

Thanks!
Dana


----------



## wblock@ (Jul 29, 2012)

Look at /var/log/maillog.  Does it show the mail going out?  Coming in?


----------



## danaeckel (Jul 29, 2012)

It shows main going out, but nothing coming in. I tried both direct IP and subdomain.

Dana


----------



## usdmatt (Jul 30, 2012)

*1) Setup your server to handle email for your domain*

Add yourdomain.com to /etc/mail/local-host-names and the email address you want to /etc/mail/virtusertable

/etc/mail/local-host-names

```
yourdomain.com
```

/etc/mail/virtusertable

```
@yourdomain.com     error:550 User unknown
me@yourdomain.com   mylocaluser
```

I've shown with the catch-all set to reject with error 550 as this is what I would recommend. You can point this at your user if you wish.
Rebuild the config files -


```
# cd /etc/mail
# make install restart
```

Make sure sendmail is enabled in your /etc/rc.conf and running.
The below command is extremely useful when you are working with sendmail and will confirm it is set up correctly locally. It should say the email address is deliverable to a local user and specify the user you added in the config above.


```
# sendmail -bv me@yourdomain.com
me@yourdomain.com... deliverable: mailer local, user mylocaluser
```

*2) Allow email into your server*

Make sure port 25 is allowed through your firewall (if you are running one) and if you have a NAT router you should also forward port 25 to your server.

Go to http://www.mxtoolbox.com and put your public IP address into their diagnostics tab to make sure the server is accessible on the Internet. You may get a few warnings about the reverse DNS (which you should get fixed eventually) but just make sure it connects for now. If you get an open relay warning (which you shouldn't with a default Sendmail config) turn Sendmail off immediately and fix that first.

This will confirm that the Internet can connect to your SMTP server.

*3) Point email for yourdomain.com at your server*

In BIND speak, you should have the following DNS configured on your domain, where 1.2.3.4 is your public IP:


```
yourdomain.com      IN MX  5 mail.yourdomain.com.
mail.yourdomain.com IN  A  1.2.3.4
```

Any third party sending email to *@yourdomain.com should look up the MX record for your domain, which lists mail.yourdomain.com as the mail server. They will connect to mail.yourdomain.com which should point to your server. (It doesn't have to be mail. - you could call it my-server.yourdomain.com if you wanted to.) If you already have a DNS name for your public IP, or are using DynDNS, you should be able to use that in the MX entry instead.


----------

