Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Setting up sendmail for SMTP usage UNIX
I managed to set up sendmail as SMTP and have it actually start up properly during boot-time. The instructions can be found here:
http://www.tijsseling.com/professional/xtipstop.html

It also explains why it did not work before.

Adriaan
    •    
  • Currently 3.25 / 5
  You rated: 2 / 5 (4 votes cast)
 
[14,005 views]  

Setting up sendmail for SMTP usage | 25 comments | Create New Account
Click here to return to the 'Setting up sendmail for SMTP usage' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
sendmail sending mail...how to receive?
Authored by: ppmax on Aug 12, '01 02:52:05PM

got sendmail working. if i check my console logs it seems that the changing hostname from AUTOMATIC to my domain name still doesnt work correctly. is this a bug or the fact that im behind the firewall built into my router? (i have a home lan--my OS X box is on the subnet at 192.168.0.110. do i need a DNS server now?

anyways, here's a clip from my mail.log files:
+++++++++++++++++++++++++++++++++++++++++++++++++
Aug 11 04:30:21 localhost sendmail[7323]: My unqualified host name (localhost) unknown; sleeping for retry
Aug 11 04:31:21 localhost sendmail[7323]: unable to qualify my own domain name (localhost) -- using short name
Aug 11 04:31:21 localhost sendmail[7323]: gethostbyaddr(192.168.0.110) failed: 1
Aug 11 04:31:21 localhost sendmail[7323]: f7BBVLO07323: from=root, size=328, class=0, nrcpts=1, msgid=<200108111131.f7BBVLO07323@localhost>, relay=root@localhost
Aug 11 04:31:21 localhost sendmail[7326]: f7BBVLO07323: to=>/dev/null, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=*file*, pri=30328, dsn=2.0.0, stat=Sent
+++++++++++++++++++++++++++

finally, how do you set up sendmail accounts to receive mail? id like to send mail to user@mydomain.com

thx
ppmax



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: adriaant on Aug 12, '01 08:53:24PM

What does the line for hostname read in your /etc/hostconfig? It seems that it is set up incorrectly. Also, make sure it is a qualified hostname.

Your users already can receive email. For example. crontab output is send to the user. To verify mail, you can use "mail", but this program is a tad non-intuitive. I don't use the GUI Mail program, but I do know you can set that one up to use sendmail. The how-to is somewhere here on Macosxhints.

adriaan



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: ppmax on Aug 13, '01 12:56:29PM

thanks adriaan--

here are the lines from etc/hostconfig:
++++++++++++++++++++++
HOSTNAME=-<MYDOMAIN.COM>- <--my domain is registered and working; i host a website
ROUTER=-AUTOMATIC- <--should i set this to the IP address of my router??
++++++++++++++++++++++

it seems like im fighting a OS X bug: when i use mail ("mail user@mac.com") upon receiving it i can check the header and it reveals the mail is from "user@localhost"...so the domain name i set above isnt being found. since my OS X box is behind a firewall (my router) do i have to set up a DNS server to resolve my internal IP address (192.168.0.xx)? here's a snip from my mail.log:
++++++++++++++++++++++
Aug 13 03:16:02 localhost sendmail[7515]: My unqualified host name (localhost) unknown; sleeping for retry
Aug 13 03:17:02 localhost sendmail[7515]: unable to qualify my own domain name (localhost) -- using short name
Aug 13 03:17:03 localhost sendmail[7516]: My unqualified host name (localhost) unknown; sleeping for retry
Aug 13 03:18:03 localhost sendmail[7516]: unable to qualify my own domain name (localhost) -- using short name
+++++++++++++++++++++
further, my terminal prompt still says "[localhost:~] ~user" i can "su root" and "hostname -s MYDOMAIN.COM" but this will only last for the duration of my login--it doesnt get set permanently.

any help would be appreciated!

thx



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: dsauve on Aug 15, '01 04:45:29PM

I was having the same error in the mail log:

> Aug 12 03:16:02 localhost sendmail[348]: unable to qualify my own domain name (localhost) -- using short name

In /Library/Documentation/Administration/Services/sendmail/README under "HOST NAME SERVICES" it says to use this form in /etc/hosts:

> 128.32.149.68 mastodon.CS.Berkeley.EDU mastodon

I'm not getting that particular error anymore.

damon






[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: ppmax on Aug 15, '01 05:03:18PM

thanks daemon--

i read this a while ago, but decided not to alter my /etc/hosts file because the header in that file tells you not to:

# Note that this file is consulted when the system is running in single-user
# mode. At other times this information is handled by lookupd. By default,
# lookupd gets information from NetInfo, so this file will not be consulted
# unless you have changed lookupd's configuration.

i dont run single user mode, so i just assumed that something had to change in NetInfo. Last nite i added another value to my /machines entry, but to no avail..

i appreciate the help--pls keep it coming

ppmax



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: dsauve on Aug 16, '01 10:34:32AM

MacFixit's front page discusses hopw to set both NetInfo and hosts file. I'll include it all here. Also, check out the post preceeding it which gives a more detailed explanation of how to set-up NetInfo:

http://www.macfixit.com/archivesx/august.01.b.x.shtml#ipnames-08-14

damon


- - -

Giving local machines names rather than IP addresses:
A follow-up

Regarding yesterday's item on assigning local names to local addresses:

Joseph Bruni adds:

* You don't have to restart the netinfo domains for changes to take effect. All changes are dynamic.
* If the machines you create in the machines section are not running OS X, you should remove the 'serves' property. The only two properties you need are name and ip_address.

Corby Tobin describes another method entirely, which "sets the hostname on the Unix end and in NetInfo":

1. Open Terminal.app.
2. Type: sudo hostname -s <machinename>.
3. Edit the file </etc/hostconfig>. You can do this via Terminal, using the pico editior (i.e., type: sudo pico /etc/hostconfig) or by opening up an Aqua text editor, such as TextEdit, with root privileges (e.g., type: sudo open <path for TextEdit.app>
4. Where the text "HOSTNAME=-AUTOMATIC-" appears, replace "-AUTOMATIC-"
with whatever name you want (no spaces, of course).
5. Save changes and quit.
6. Open up NetInfo Manager.app. Click the lock icon to unlock the app so you can edit settings.
7. The second window pane will have the things that can be set for /. Click on "machines" and in the third pane click on "localhost."
8. In the bottom pane, click on the hierarchial arrow to show all items for localhost.
9. Click on the localhost listed within that. From the Directory menu, select New Value.
10. Type in the machinename you want and hit return, then drag it so it's above localhost.
11. Select "Save" from the Domain menu, confirm the update and quit.
12. On the next restart the machinename will be whatever you set.



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: ppmax on Aug 16, '01 01:21:25PM

thanks for the pointers...but one of those tips doesnt work. try this yourself:

in the terminal type hostname -s <machinename>
quit termainal...open up a new session. the machine name is set. now restart. this info is lost.

also, ive edited the /etc/hostname file....

but after i made the changes to netinfo, i tested sending mail and it now appears that my domain is being appended correctly. messages now come from user@MYDOMIAN.COM but the problem still remains: whenever i reply to this address it bounces. do i have to create users/aliases in sendmail?

thx agian



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: dsauve on Aug 16, '01 02:23:54PM

I think we have similar network setups. I have a mac on a router behind DSL modem. The router is set to listen to port 25. I have sendmail working, but I haven't yet set my website's MX record to point to my static ip address, so I can send mail from my mac, but I can't reply back to it (actually, my MX records are still pointing to my ISP's mail server, so I can get mail, just not through my server). My first question, then, are your MX records pointing to your static ip?



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: ppmax on Aug 16, '01 04:17:48PM

FYI: i now have everything working. the key was that apparently sendmail looks to the /etc/hostconfig file for info about the hostname of the machine. because my machine is on an internal LAN, i entered "dualg4.mydomain.com" for the hostname. to further confuse matters, i had previously followed a tip for netinfo to add a value for the /machines record so that my internal IP address would resolve to my machine name. thus dualg4 = 192.168.0.110

anyways, the key (provided you have changed you MX records accordingly) is to set your hostname in /etc/hostconfig to your fully qualified domain name. my sendmail now sends and receives mail from my domain. cool! (was a bit easier to config with webstar...)

another slighly confusing issue is where hostname -s is written. if you open a terminal and set this (hostname -s MYDOMAIN.COM) it will reset to localhost once you reboot your machine.

lastly, its a bit odd to me that netinfo and the unix underwear dont share the same info. if they do it certainly doesnt seem like it, considering my recent troubles getting this stuff to work.

any netinfo geeks out there?

thx again for everyone's help



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: robh on Aug 16, '01 04:52:29PM

> anyways, the key (provided you have changed you MX records accordingly) is to set your hostname in
> /etc/hostconfig to your fully qualified domain name. my sendmail now sends and receives mail from
> my domain. cool! (was a bit easier to config with webstar...)

I don't use a domain name in mine..

% grep ^HOST /etc/hostconfig
HOSTNAME=chad

OSX doesn't seem to care what my domain is.

I use /etc/mail/local-host-names to tell sendmail what domain names I use for email.



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: ppmax on Aug 17, '01 01:07:52AM

thanks robh...

anyways, care to post your /etc/mail/local-host-names? im really having a hard time understanding how the heck domain names and host names are stored, passed around and resolved. here's a list of stuff ive done. all i know is that all my servers are working...finally.

1. i changed /etc/hostconfig to HOSTNAME=-MYDOMAIN.COM-
2. i never changed the ROUTER=-AUTOMATIC- <--looks like i should change this to my router address
3. i added another names property to / machines localhost. now it reads:
ip_address 127.0.0.1
name (MYDOMAIN.COM, localhost)
serves ./local
4 i duplicated this record and renamed it dualg4
ip_address 192.168.0.110 <--my internal ip address
name (dualg4)
serves ./local
5. ive tried setting the hostname -s in the terminal...this just reverts to localhost upon restart


any comments?

thanks



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: robh on Aug 17, '01 05:03:02AM

>anyways, care to post your /etc/mail/local-host-names?

basically it contains parts that appear on the right hand side of an '@' in an email address, so if I receive mail for 'rob@foo.bar.com' and 'another@xyz.net', then /etc/mail/local-hosts-names would contain:

foo.bar.com
xyz.net

AFAIK, this tells sendmail to deliver mail for these two domains to users on this machine, and not to try to find another machine (locally or on the net) that will accept the mail.

> im really having a hard time understanding
> how the heck domain names and host names are stored, passed around and resolved.

I don't think how those work is relevant to setting up sendmail as such. To change the behaviour of name resolving for email purposes, you need to look into 'MX' records for your domain, and chances are that it's your ISP that controls this and they probably offer no way for you to change this. If you've bought your own domain name then you probably do have control of your MX records, in which case you need to configure this via whatever service your domain name provider offers - that provider must have a place where you can give it the IP address of your machine (e.g. for www access) and it may also ask you for an IP address of your mail server.

Say you owned myname.com and have a single computer at home.
Run 'nslookup' (no flags)
Type myname.com at the '>' prompt, and you'll be told the IP address of your machine
Type "set querytype=MX"
Type "myname.com" again
You'll now be shown where email for myname.com gets sent.
Unless that matches your home computer, sendmail on that machine won't directly receive email sent to @myname.com

If you've been collecting email via POP (or similar) from an ISP then it's 90% likely that your mail will stay on your ISPs mailserver and not get delivered to your osx box. My ISP lets me collect via POP or receive the email via SMTP, so I can run sendmail and when I dial in, sendmail starts to receive new email that's been stored by my ISP. Check to see if your ISP offers SMTP delivery, if it does then you need to enable it to use sendmail. but make sure sendmail is working properly before switching on SMTP delivery.

I've heard that some ISPs will block the email port to prevent people running their own SMTP server.

Also note that having your own mail server can open you up to abuse from spammers. If you mess up the configuration, your email can also bounce without you noticing.

> here's a list of
>stuff ive done. all i know is that all my servers are working...finally.

>2. i never changed the ROUTER=-AUTOMATIC- <--looks like i should change this to my router address

Your networking obviously works, so don't change that setting. It's nothing to do with sendmail. Sorry if my mentioning it confused.

>5. ive tried setting the hostname -s in the terminal...this just reverts to localhost upon restart

don't bother using 'hostname'. It doesn't make a permanent change that survives reboots.



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: dsauve on Aug 17, '01 04:07:46PM

Thanks for helping me get sendmail working. I did everything that was suggested, and the final piece was waiting for DNS to update my domain name to my new IP number.

I'm sending and receiving!

Now if I could just get my SSH to work between machines....

damon



[ Reply to This | # ]
sendmail sending mail...how to receive?
Authored by: robh on Aug 16, '01 04:36:19PM

I've been using sendmail for both incoming and outgoing email for months now.

From what I've seen, sendmail uses the email aliases setup by NetInfo. Anything in /etc/mail/aliases is ignored. You can import an existing aliases file into NetInfo with "niload aliases ."

For the record, my /etc/hostcofig has these:

HOSTNAME=chad
ROUTER=10.1.2.1
MAILSERVER=-YES-

(if you're a newbie, DON'T copy "chad" - my machine name, or "10.1.2.1" - my LAN router IP)

I have an /etc/mail/local-host-names file that tells sendmail the names of the domains that I use AND OWN, and an /etc/mail/relay-domains containing the same domains - this is to stop spammers using my machine to relay their spam to any other domain.

I also have an /etc/mail/sendmail.cf, but I don't remember if it came with OSX or if I copied it there from my old FreeBSD box.
% wc sendmail.cf
1214 5788 35103 sendmail.cf
I know I didn't need to alter the sendmail.cf

I hope that helps someone.



[ Reply to This | # ]
one last step...
Authored by: Nighzlie on Sep 07, '01 01:33:08PM

After following these instructions, sendmail still wasn't working. I kept getting a message that it could not open /etc/mail/local-host-names because it is a world wrteable directory. I used chmod 755 /etc/mail without success. So instead I just edited /etc/mail/sendmail.cf and commented out the line that says Fw/etc/mail/local-host-names.
This did the trick. It looks like this line in the config file is related to receiving mail, which I'm not trying to do so no big deal.
Good luck!



[ Reply to This | # ]
one last step...
Authored by: fxdl on Dec 20, '01 02:08:02PM

A better fix to this problem is:

1) Open up the config file using your favorite editor (i.e. Pico) and using the 'sudo' command since you probably don't have write access to the file:
sudo pico /etc/hostconfig

2) Make the change indicated below and save the file
Change:
#0 DontBlameSendmail=safe

To:
#0 DontBlameSendmail=GroupWriteableDirPathSafe

I read this info on pg. 1141 of the excellent "Mac OS X Unleashed" book (ISBN: 0-672-32229-3). This book and macosxhints.com have been my two best friends...



[ Reply to This | # ]
one last step...
Authored by: vesalius on Dec 21, '01 11:25:17AM

Don't you mean to edit "/etc/mail/sendmail.cf"? I can find no reference to "#0 DontBlameSendmail=safe" in /etc/hostconfig, but "#0 DontBlameSendmail=safe" is located in the sendmail.cf file?



[ Reply to This | # ]
No luck
Authored by: SeanAhern on Jan 18, '02 01:59:45PM

No effect. I changed:

#O DontBlameSendmail=safe

to

#O DontBlameSendmail=GroupWriteableDirPathSafe

and I still get the

/etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory

error.



[ Reply to This | # ]
No luck
Authored by: dsauve on Jan 18, '02 05:31:22PM

I think a recent OS X update reset the permissions on mail-related files. My mail server was down for three or four days two weeks ago until I realized the permissions error was keeping sendmail from starting.

I played around with it with no luck until I went back to the original OS X Hint above and went throught the step-by-step process described here:

> http://www.kung-foo.tv/xtips.shtml

Try these permission changes, and let us know if it works:

sudo chmod go-w / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue
sudo chown root / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue

-damon



[ Reply to This | # ]
No luck
Authored by: dsauve on Jan 18, '02 05:32:12PM

I think a recent OS X update reset the permissions on mail-related files. My mail server was down for three or four days two weeks ago until I realized the permissions error was keeping sendmail from starting.

I played around with it with no luck until I went back to the original OS X Hint above and went throught the step-by-step process described here:

> http://www.kung-foo.tv/xtips.shtml

Try these permission changes, and let us know if it works:

sudo chmod go-w / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue
sudo chown root / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue

-damon



[ Reply to This | # ]
No luck
Authored by: sharumpe on Jan 28, '02 02:18:06PM
You probably did this, but just in case: If sendmail was running while you made the change, you need to kick it.

# ps -auxww | grep sendmail
# kill -1 pid

pid is the numeric process ID from the ps output.

Mr. Sharumpe

[ Reply to This | # ]
No luck
Authored by: sharumpe on Jan 28, '02 02:25:26PM
Disregard my previous post - you need to remove the # from the front of that line. The final result should read:
O DontBlameSendmail=GroupWriteableDirPathSafe
Mr. Sharumpe

[ Reply to This | # ]
new address
Authored by: mbanks on Jan 27, '02 10:08:23PM

If you're just looking through this for the first time, the new web address for this site is: http://www.kung-foo.tv/xtips.shtml

I keep losing it, so perhaps this is for my own benefit... :)



[ Reply to This | # ]
sendmail on OS X
Authored by: icalzone on Feb 18, '02 04:19:38PM

After going through all of these messages i finally got sendmail to work. The only problem is that I can't send from sendmail to anybody else in my organization. I can send outside of our network just fine. We have our email server on another machine. I am just trying to run send mail on our webserver to handle SMTP for some PHP scripts. It appears that sendmail is trying to accept mail from itself for anybody with the same domain name as the webserver. I have even tried setting our mail server address to handle all local traffic in the sendmail.cf file. Anybody have any ideas? Any help would be greatly appreciated



[ Reply to This | # ]
newer address
Authored by: Brad Puett on Jun 06, '02 02:29:06AM

In case of problems, I noticed the URL is now:

http://www.kung-foo.tv/xtips.php



[ Reply to This | # ]