# Sendmail (or other) relaying help please :)



## chillybsd (Mar 17, 2011)

Hi everyone, first time poster, novice FreeBSD user since 4.0.

Here's my problem.  I have a very small private network that needs a server that can accept emails from network devices and relay them to their destinations.  

I have a dell 3110CN network printer that can send email alerts using smtp, but only on port 25, or ports 5000-65000 (can specify the standard 25, or anything custom between 5000 and 65000).  The printer can use no smtp authentication, or a few smtp auth types.

Here's what I did so far.  I set up FreeBSD 8.2 as a simple server running sendmail and really not much other than what comes with the standard install.  It's on the network no problem, can ping other network devices (by ip address) and can be pinged (by ip address).  There's really no domain set up (it's an older windows network).  The server has full outbound internet connectivity (nslookups and pings work).

So, on to the problem.  I have a dell printer on the network and it can be configured to send email alerts for things like low toner, paper jam, and the like.  The printer has a hostname (dell47294 or something) but no domain name.  In the email config, I can specify the smtp server (I set the ip address of the FreeBSD server), the email address to send as, and some smtp auth options for username and password for authentication.  

I won't go into what sendmail options I set using the config files, but here's what happened.  The printer is sending mail alerts to the FreeBSD server (I can see the mqueue files) and the server is _trying_ to send the emails to their delivery domains (I'm testing by telling the printer to send email to my personal@gmail account, using the FreeBSD server as the smtp server).  When I *tail -f /var/log/maillog*, I can see it trying to send and then just hanging until it times out.  Then it tries again in a few minutes to another gmail MX record (alt-something.gmail.com) - so the server is trying.  I'm just not sure that the server is allowing itself to send the emails or something - it's really difficult to describe.  

So basically, here's what I need to know how to do  - configure sendmail to allow relaying 100% (I know this is bad, but it's an internal-only box with no inbound access whatsoever). I need to know which files I need to change, which options, and so on.  I'm not even tied down to using sendmail if another option would be simpler/more reliable.

I'm hoping I'm just missing something easy here.  Please help!    I'm not sure how to proceed, or how to troubleshoot it further, so if you need more information just say the word.  Thanks everyone!


----------



## lbol (Mar 17, 2011)

from what you describe I assume the mails have been accepted by sendmail on your server. So it's not a relaying problem.
Looks like gmail is not willing to accept the mail from your server or your server is not able to set up a connection to the gmail server.
Can you telnet on port 25 to the gmail server? Pls provide more details from your maillog file.


----------



## wblock@ (Mar 17, 2011)

It's not a relay problem, or sendmail wouldn't accept the message.  Mostly likely you just need to smarthost through your ISP:

```
dnl Dialup users should uncomment and define this appropriately
define(`SMART_HOST', `your.isp.mail.server')
```


----------



## DutchDaemon (Mar 17, 2011)

Make sure your email leaves the server with a valid hostname (DNS resolvable and with valid MX records). To me it sounds like the receiving smtp server (gmail) is timing out because it can't find these data (usually timeouts are set to ~75 seconds). Post the relevant lines from the *maillog* here.


----------



## chillybsd (Mar 17, 2011)

Thank you all for the fast replies.

Yes, sendmail is accepting the mail messages from the printer, and sendmail is initiating connection with gmail's servers, but after that the process times out.  Once it times out, sendmail initiates connection with the next gmail server listed in the MX records, and times out again.  This happens for days (I believe 5 days is the max time for retries).

I will look into the smarthost option and see if it will work for me.  

Another problem with this setup is that our internet access is not on a business account so I have no way to create MX records.  

I wonder, would it be possible to configure sendmail to accept mails, then authenticate to gmail's or my ISP's servers for delivery, similar to how Outlook or Thunderbird would accept emails written by me then authenticate to the server for delivery?  That is the method I tried initially, to have my devices connect directly and authenticate to the ISP servers, but the problem with that is my ISP mail servers only accept smtp on port 587 which my network devices do not support.

Again, I am open to using software in addition to, or instead of sendmail to get this working.  Thanks


----------



## DutchDaemon (Mar 17, 2011)

If your 'From' address (a.k.a. Return-Path) is not valid, no amount of authentication will help. The other side will still not be able to resolve the address, or will simply refuse it because it has no IP address or MX records associated with it.


----------



## chillybsd (Mar 18, 2011)

Hmm, okay that's a good bit to know too, thanks.  I'll see what I can come up with tomorrow.  If I get it working, I'll report back on what I did.


----------



## hblandford (Mar 18, 2011)

What is the from address for these emails once they are leaving your server?  If they are not valid, ie there is no MX record for the domain they are coming from, most mail servers will not accept them.  Is it possible to see a relevant part of /var/log/maillog?  One of the first timeout attempts.  grep the message id field and post the lines in.


----------



## DutchDaemon (Mar 18, 2011)

I think that's what I just posted, hblandford  ...


----------



## chillybsd (Mar 19, 2011)

lbol said:
			
		

> from what you describe I assume the mails have been accepted by sendmail on your server. So it's not a relaying problem.
> Looks like gmail is not willing to accept the mail from your server or your server is not able to set up a connection to the gmail server.
> Can you telnet on port 25 to the gmail server? Pls provide more details from your maillog file.



This was the first thing I tried today - telnet to gmail on port 25... and I feel like a complete tool now lol.  Sure enough, AT&T Uverse blocks port 25 outbound by default.  

I have worked on servers and desktops since 1998, from single-server shops to multi-site corporations (never sendmail or on any BSD variants though), and have never experienced any ISP blocking port 25 until today.  I google'd a bit and there are plenty of cases that say AT&T Uverse blocks it, and the fix is to simply call them and ask them to unblock it.

So, once we get the port unblocked, I will be able to test it for real, and I am guessing that everything will work just how I had it set up originally.  I could tell from the maillog that sendmail was initiating a connection, but then it just hung.  I assumed that the problem was my inexperience with sendmail/FreeBSD, but it just goes to show that you should always start with the basics when troubleshooting even what seems like a vast, complex problem.  

I'll report back next week with any updates   Thanks again to everyone!


----------



## DutchDaemon (Mar 19, 2011)

I do feel that ISPs blocking in/outbound SMTP traffic should do so with an RST packet (hard reset) and an 'administratively prohibited' flag instead of silently dropping the packet and not adding to diagnostics.

P.S.: chillybsd, I looked up your (posting) IP address, and even if you get your ISP to unblock your smtp port, you will find that outbound mail will not be accepted my a great many ISPs and email providers because it is listed as a residential or dynamic IP address (see e.g. the Spamhaus PBL, which 'runs' on millions of mail servers (including all of mine)). You are advised to use your ISP's relay server for outbound email instead of trying to deliver directly-to-MX. You will find the latter frustrating to say the least.


----------



## chillybsd (Mar 20, 2011)

Thank you for the additional information.  I only post from my home account, but I presume the same situation applies to where the mail server will be - behind a dynamic IP address.  I will keep that in mind as I try to make things work   Best case scenario, I can get relaying working on sendmail (which I think it has been, but unable to be fully tested) and then configure it with the smarthost options to have it connect to my ISP's relay server.  

I do have one followup question.  I've been reading a lot about the different mail servers available and Postfix seems to come up a lot.  Would it be in my best interest to switch over to Postfix before I get too much into sendmail?  My setup is very, very simple, but since I have to learn one, I might as well start with "the best" all around!  Thanks!


----------



## lbol (Mar 20, 2011)

> I do have one followup question. I've been reading a lot about the different mail servers available and Postfix seems to come up a lot. Would it be in my best interest to switch over to Postfix before I get too much into sendmail? My setup is very, very simple, but since I have to learn one, I might as well start with "the best" all around! Thanks!


I think there is no "best" choice. I would recommend to go with the tool you are most comfortable with. Both mail servers will be capable to meet your needs.


----------



## DutchDaemon (Mar 20, 2011)

Also note that Postfix just had this, so 'the best' is a matter of opinion, to say the least. Sendmail is part of the base system and pleasantly licensed.


----------

