# Sendmail



## sepia (Mar 24, 2001)

Never had problems with this on PB, but I've got the final now and it's really frustrating me.

Sendmail won't start. It keeps telling me that /etc/mail/local-host-names is in a group writable directory. Changing the permissions doesn't do a thing.

This question has been posted before, but with no good response. Any ideas?


----------



## ChrisL (Mar 24, 2001)

Its the root ( / ) directory that is group writable. You can change it to mode 755 and fix the problem with:

chmod 755 /

(as root). But You'll need to be root to add directories or create files now (not just admin priviledges. 

Another option would be to add the conf DONT_BLAME_SENDMAIL to your m4 config file.

I myself am trying to figure out why it won't receive mail.


----------



## gdif (Mar 24, 2001)

It's not working because it's sleeping.  Check your /var/log/mail.log and you'll see entries like this:

Mar 24 19:52:15 localhost sendmail[1700]: My unqualified host name (localhost) unknown; sleeping for retry
Mar 24 20:01:00 localhost sendmail[1741]: My unqualified host name (localhost) unknown; sleeping for retry
Mar 24 20:03:23 localhost sendmail[1749]: My unqualified host name (localhost) unknown; sleeping for retry
Mar 24 20:13:35 localhost sendmail[1772]: My unqualified host name (localhost) unknown; sleeping for retry


Damned if I can figure out how to fix it though.  Nothing I've done seems to work.

--gdif


----------



## sepia (Mar 25, 2001)

Yes, I got sendmail to start listening by chmod'ing the root directory. (Figured it out shortly after posting my first message.)

Now it won't recognize emails to users. (User unknown error.) I've got the domain in my local-host-names file. I'll try the relay-domains file now, but that seems wrong...


----------



## gdif (Mar 25, 2001)

Well, I did the chmod, that fixed that problem.  Found where to put the domain name (/etc/hostconfig) but now any mail I try to send gets "no route to host" errors generated in mail.log.

What's odd about that is that the error has the domain name and the ip address of the host, but then it says it can't get there.

Thoughts?

--gdif


----------



## stovak (Mar 25, 2001)

I had this SENDMAIL problem with the pubic beta. Occasionally I would send an email and for some reason, Sendmail would have problem looking up localhost. I never solved it, but I noticed I didn't have it after I started doing my own DNS locally. Getting named running on the machine seemd to satisfy this error.


----------



## ChrisL (Mar 25, 2001)

Solved a number of problems, although perhaps non-conventionally.  

First things first, /etc/mail/local-host-names _has to_ contain the domain(s)/host(s) for which you are receiving mail. 

Next, although not entirely necessary, sendmail complains a lot less and starts up faster if your hostname is set.  You can set it manually with "hostname your.hostname.here.com", or perhaps in /etc/hostconfig under the "HOSTNAME=" line.  I haven't rebooted yet to verify this, but from the /System/Library/Startup/Network script seems to verify this.  It'll sleep and retry if you don't, but eventually it'll startup for queing.  

After a few frustrating hours trying to figure out why "mail.local" didn't have the correct permissions to write to /var/mail, I got it to work by making it setuid root (ie: chmod u+s /usr/sbin/mail.local).  Now, this probably isn't the greatest idea, but it did deliver mail.  I recompiled the latest sendmail (8.11.3) just to be sure that it wasn't an Apple problem, and the same thing is required for that build.  It talks about some different compile options for SYS V based Unixes, but BSD is not, so I would think they don't apply.

A more desirable solution for me was to compile and install procmail (www.procmail.org) and enable it as the local mail delivery agent in the sendmail.cf file.  For my  installation, the following config options in the .m4 file did the trick:

define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')
FEATURE(local_procmail)

Or, alternatively, you can edit the Mlocal file in /etc/mail/sendmail.cf similar to the following:

Mlocal,         P=/usr/bin/procmail, F=lsDFMAw5:/|@qSPfhn9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
                A=procmail -Y -a $h -d $u

Hope this saves some time for some people.


----------



## Zim (Apr 3, 2001)

First question... is the definitive test that one can telnet to port 25?
(using 127.0.0.1)?  ie. if your ISP blocks incoming port 25, will that be a local loopback before it can get blocked?  (I'm assuming yes).

Ok, what I have tried so far from tips I have seen....

- I have done a chmod 755 on /
- I have changed /etc/hostconfig to read
hostconfig:MAILSERVER=-YES-
- I have done a chmod 755 on /private/etc (this cleared up a LOT
of msgs in /var/logs/mail.log)

my permissions....

top level: drwxr-xr-x  30 root  admin      976 Apr  3 09:37 .

lrwxr-xr-x   1 root  admin       11 Apr  3 09:37 etc -> private/etc
drwxr-xr-x   7 root  wheel      264 Apr  3 09:38 private

in private:
drwxr-xr-x  70 root  wheel  2336 Apr  2 20:17 etc


At this point my /var/logs/mail.log has

Apr  3 09:46:11 localhost sendmail[225]: My unqualified host name (localhost) unknown; sleeping for retry

Now I do have a dyndns acct, or should I use my Roadrunner, but then that really doesn't have a hostname, does it?  Exactly what does sendmail need the hostname for?

What I'm trying to accomplish.... I'm a dinosaur, I admit it.  I am thrilled to finally have unix on my Mac.  I love both the cli and the gui.  finally they are unified.

I'm trying to consolidate my mail accts.  One thing I value tho is being to get to mail mail from virtually anywhere any time.  Also I want to consolidate mail from several accts I have.

So I want to run fetchmail to grab my mail from various points and it passes mail off to sendmail (hence my need for sendmail as a delivery agent?) into /var/mail/$USER.  From there I will use elm (told you I'm a dinosaur), which I finally got to compile.  Its important to me NOT to need a gui.  Yes I'm sure there are plenty of GUI mail programs that can fetch from multiple accts, but I want something simple.

Anyway,  I cannot telnet to 25 yet (host refused connection), and a ps-auxww shows no sendmail process running.

Using procmail as the MTA for fetchmail is another option I suppose, but I'd like to at least understand how to get sendmail working and go from there.

Thanks for any help,
Mike


----------



## sepia (Apr 3, 2001)

If sendmail isn't a running process start it like this:

/usr/sbin/sendmail -bd -q15m

or -q1h, or whatever.

This seems to be a problem, though. Even when MAILSERVER is set to "Yes" in hostconfig, the daemon doesn't seem to start when I reboot. I have to do it manually.

Another tip that might be helpful. Set your hostname and domainname using the commands:

hostname mymachine
domainname mydomain


----------



## Zim (Apr 3, 2001)

Ok, making progress 

I had to make sure /etc/mail did not have group write permissions.

then following your advice I did

sudo domainname dyndns.org
sudo hostname my_dyndns_subdomain

sudo /usr/sbin/sendmail -bd -q1h &

and I could finally telnet to port 25.

Fetchmail was then able to retrieve my POP mail.

I tried outgoing mail and did not have any luck.

I found that I needed to set hostname to my full hostname, not just the machine under the domain. As far as I could tell domainname wasn't being picked up at all (my mail was coming from me@hostname only, not me@hostname.domainname as I thought it might).

Anyway, at this point, outgoing mail works.

Fetchmail can now retrieve outside mail.  I'm having a mailbox lock problem with elm, but I guess I can pound on that.

So I tried sending myself some mail (to zimmy@zimmy.dyndns.org)

My mail I send from an outside acct bounces... and I get a message about mail relaying being denied... that _could_ be RoadRunner filtering port 25?

So from my machine I telnet to port 25
mail from: me@outside.isp
rcpt to:zimmy
data
testing
.

Oh, I also found that I needed to set host = myhost

And that works.  So I guess RR is blocking incoming port 25?

Thanks for the help,
Mike


----------



## sepia (Apr 3, 2001)

Oh yeah, I forgot it had to be hostname full.host.name.

RR isn't blocking port 25. If that were the case you wouldn't be getting a "Relaying Denied" message from your mail server at all. Check /var/log/mail.log

Make sure you've got your domain name in the local-host-names file in /etc/mail.


----------



## Zim (Apr 3, 2001)

First let me say that I greatly appreciate the replies 

Can you supply the format for an entry in the local-host-names file?

Mine currently is at 0 length 

And looking around at the various *nix systems to which I have access, I can find no example to go by.

So you are correct, RR is not blocking.

in /var/log/mail.log I have

Apr  3 14:50:27 localhost sendmail[932]: f33IoQG00932: ruleset=check_rcpt, arg1=<zimmy@zimmy.dyndns.org>, relay=smtp3.vnet.net [166.82.1.33], reject=550 5.7.1 <zimmy@zimmy.dyndns.org>... Relaying denied

So its getting to me, I guess my machine still isn't sure what to do with it, or thinks it is for someone else and denying wanting to relay it?

Note, I have not editted HOSTNAME=-AUTOMATIC- in /etc/hostconfig yet either (again, not certain of the needed format).

Thanks,
Mike


----------



## Zim (Apr 4, 2001)

One further thing I found I needed to change was in 

/etc/rc.boot

hostname yourhost.domain

Sendmail still does not start at boot, but I can launch it and now receive mail to my username.  So that is good progress 

Mike


----------



## sepia (Apr 16, 2001)

1. chmod g-w /
Make root directory not group writable.

2. Edit /etc/hostconfig:
HOSTNAME=-my.domain.com-
# Not convinced this really does anything, but oh well.

3. Edit /etc/rc.boot:
hostname my.domain.com
domainname domain.com

4. Edit /System/Library/StartupItems/Sendmail/Sendmail:
/usr/sbin/sendmail -bd -q1h
# removed the "&", helps it start on boot

5. Edit /etc/mail/local-host-names
my.domain.com
domain.com

Did I miss anything? Let me know and we'll repost.


----------



## sepia (Apr 16, 2001)

Original Message (somebody tell me how to do the quote block):

Apr 3 14:50:27 localhost sendmail[932]: f33IoQG00932: ruleset=check_rcpt, arg1=, relay=smtp3.vnet.net [166.82.1.33], reject=550 5.7.1 ... Relaying denied 

It looks like you are talking to your Mac from a remote location and trying to pass mail through to a recipient that is not local to your Mac. By default sendmail won't do this! (Wouldn't want spammers using your Mac for their dirty little activities.)

Unfortunately, Darwin doesn't include support for an "access" file with its default build. You'll have to download sendmail and make a "sendmail.cf" file with support for the access file. (Maybe virtusertable while you're at it.)

I'll try to get around to posting instructions for that if no one else does.


----------



## Zim (Apr 17, 2001)

god bless you for item #4.  That finally fixed my problems.

Mike


----------



## sepia (Apr 17, 2001)

---- Original message -----
Unfortunately, Darwin doesn't include support for an "access" file with its default build. You'll have to download sendmail and make a "sendmail.cf" file with support for the access file. (Maybe virtusertable while you're at it.) 
---------------------------------------

I take it back, silly me. While you can build the access file, an easier solution is to add the machine you need relaying for to the file /etc/mail/relay-domains

Then send a hangup signal (kill -HUP) to sendmail and the machine you're coming in from will be able to relay mail.


----------



## gaboosh (Apr 25, 2001)

Sepia-

Do you think you could elaborate, or plain ol' explain, what you mean when you say:

an easier solution is to add the machine you need relaying for to the file /etc/mail/relay-domains 

how do we "add the machine" and does that mean that if I want to go away and use my server at home for smtp, i can't unless it's in the relay-domains file?

Thanks.

Gabriel


----------



## sepia (Apr 25, 2001)

Yes, I'll try to explain:

Under the default, out of the box install, the SMTP server will not relay mail (that is, accept mail for a user not  on the local machine) unless you're connecting from a machine that's 1.) the local machine 2.) a machine in the relay-domains file.

Try this:

Connect to a machine that's not your Mac. Get a shell prompt.

You type:
telnet my.macs.address 25

You see:
Connected to my.macs.address.
Escape character is '^]'.
220 my.macs.address ESMTP Sendmail 8.10.2/8.10.2; Wed, 25 Apr 2001 21:43:19 -0500 (CDT)

You type:
MAIL FROM: me@myaddress

You see:
250 2.1.0 me@myaddress... Sender ok

You type:
RCPT TO: mybuddy@yahoowhatever.com

You see:
550 5.7.1 mybuddy@yahoowhatever.com... Relaying denied

You type:
QUIT

You got relaying denied because the machine you're on is not authorized to pass mail through the server. If you were to address the message to a local user, it would have accepted it. But you addressed it to someone somewhere else. Hence relaying denied.

Now try the same after you've added a line in relay-domains that is the IP address or host name (ie another.machine.com) of the machine you're trying to connect from. This time it will work. Make sure you hangup sendmail (kill -HUP _pid_) after editing the relay-domains file.

Yes, this probably confuses the issue more, but I'm willing to keep talking until I actually make sense so just ask.


----------



## sepia (Apr 25, 2001)

But to actually ANSWER YOUR QUESTION:

Yes, that's what it means. You can't go away and use your Mac as an SMTP server.

You add the machine to your relay domains file by simply adding a line that is the host name. A sample relay-domains file could look like this:

machine1.mydomain.com
machine2.mydomain.com
192.168.0.54

That's pretty much it.


----------



## gaboosh (Apr 25, 2001)

sepia-

this totally helped and explained it, you're definitely the man.

so, that's a bummer. i mean, i understand how it would be a spam/security risk to not have the user given access manually.... but don't i need to use my login/pass anyway to get into the smtp server? (i.e. spammers wouldn't have that)

thanks again for all this help. with the help of guys like you and os x's unix base i feel like i'm really gaining a whole new understanding of computing.

g


----------



## marmoset (Apr 26, 2001)

> _Originally posted by gaboosh _
> *so, that's a bummer. i mean, i understand how it would be a spam/security risk to not have the user given access manually.... but don't i need to use my login/pass anyway to get into the smtp server? (i.e. spammers wouldn't have that)
> *



When spammers "hijack" an open-relaying SMTP server,
they don't "get into" it, they just bounce messages
off of it.  The way SMTP works is that it just takes
RFC-compliant message and does something with it, where
"something" is generally one of three things:

1. Accept it for delivery to a local user.
2. Reject it (for various reasons)
3. Send it on for someone/thing else  on the
   internet to handle.

Number 3 generally isn't a problem when you're talking
about a message from a well-behaved local (to your network)
user or service. When that message comes from an outside
spammer, though, #3 can be a _huge_ problem... that's
why Sendmail now defaults to disallowing #3 from
outside hosts.


----------



## sepia (Apr 26, 2001)

Yes, he's right. There's no username or password required to talk to an SMTP server.

On the other hand, you do need a username and password to talk to a POP or IMAP server (for retrieving your mail from afar). If you're going to set up a POP/IMAP server, I strongly recommend University of Washington IMAP.


----------



## gaboosh (Apr 26, 2001)

Ok. well thanks anyway for all the help guys, atleast i can use my server with authorized clients.

adios.
g.


----------



## kellywestbrooks (Apr 26, 2001)

I just got finished compiling and installing sendmail 8.11.3 on Mac OS X 10.0.1 on a 350 MHz iMac w/ 64 MB of RAM and it seems to work like a charm. I am no unix guru, but heres what I did:

First off, I downloaded the newest version of sendmail from the following address:

ftp://ftp.sendmail.org/pub/sendmail/sendmail-8.11.3.tar.gz

and expanded it using Stuffit Expander

Then at the terminal, cd'd into the sendmail folder created by stuffit, then became root. next, I read the file INSTALL, which gives you all the installation instructions you need, but there are some little details that it leaves out. Basically, the first step is to type in:

sh Build

which runs the 'Build' shell script and compiles the source code. Then, you cd youself into cf/cf and execute the following command:

cp generic-bsd4.4.mc config.mc

and then

pico config.mc

and at the end of the file, I added the line:

FEATURE(promiscuous_relay)

and saved the file. Now, Unix diehards will tell you that this is a big security no-no, but it *will* take care of any "550 5.7.1 relaying denied" errors you might get. Basically, it makes things work at the risk of allowing any sort of email to pass through your box.

next, i typed in

sh Build config.cf
cp config.cf /etc/mail/sendmail.cf
cd ../..
sh Build install

and everything was supposed to work at this point, but it didnt. so, I manually copied the sendmail binary to the right place with the following command

cp obj.Darwin.1.3.PowerMacintosh/sendmail/sendmail /usr/sbin/sendmail

Then, I went into /etc/hostconfig and edited the HOSTNAME and MAILSERVER lines

next, typed in

chmod 755 /
reboot

in the terminal, and when i came back online, sendmail was still not running. finally went back into root and typed in

/usr/sbin/sendmail -bd

and things started working fine.

the only thing left to do is write a little script that executes on startup to execute the '/usr/sbin/sendmail -db' line, and i'll be as happy as flies on sh*t.

--kelly westbrooks


----------



## gaboosh (Apr 26, 2001)

kelly-

if you go into /System/Library/StartupItems/sendmail/sendmail there is an extra "&" after a line towards the end (i'm at work, thus can't look at it now). When I took out that & Sendmail started to load with the system. Takes a bit of time, but then again I've got an iMac Rev A...

good luck.

g


----------



## Zim (Apr 27, 2001)

Just a guess, but I'd bet my first 25 cents that the Build install failed b/c you needed to execute it as root to overwrite the previous sendmail.

ie... sudo sh Build install

Mike


----------



## sepia (Apr 27, 2001)

> Just a guess, but I'd bet my first 25 cents that the Build install failed b/c you needed to execute it as root to overwrite the previous sendmail.



... not if you su'd to root in the first place:

tcsh>su
Password:

#root:tcsh> sh Build install


----------



## mkwan (Jan 28, 2003)

[localhost:~] kwan% can not chdir(/var/spool/clientmqueue/): No such file or directory

I get this error after turning on mailserver (on the hostconfig file) and changing the permissions on the root directory.  I went to the spool directory and found 'mqueue' not 'clientmqueue'

what do I do now?


----------



## mixup186 (Oct 17, 2011)

The simplest test that I know of to see if sendmail can deliver mail from your 
system is to give this command:

/usr/sbin/sendmail -v <email-address>

Then on the next line put the text of your message, like:
"testing to see if sendmail can deliver mail."

When you are done typing your text put a single period '.' on a line by itself. 
Then sit back and watch what happens.

Here's an example from my system:

w139:~] ramos% /usr/sbin/sendmail -v me...@RichRamos.com
testing to see if sendmail can deliver mail.
.
me...@RichRamos.com... Connecting to w137.z208176063.chi-il.dsl.cnc.net. via 
esmtp...
220 gw2.r2tek.com ESMTP Sendmail 8.11.3/8.11.3; Fri, 1 Mar 2002 23:04:21 -0600 
(CST)


----------

