Wow, so this project took me almost all weekend to complete. I am trying to get a maillist server running to also power a mailman installation. I tried to use my virtual private server, it overwhelmed it and my server started having issues; although I have finally deduced a great optimization of those settings (which I still have to post at some point).In any case I have to credit this page with helping me most of the way; but I think I might have missed something or perhaps it is missing a small be key entry. In any case, I will provide you with my exact files (Without the domains).This installation was done on ubuntu. Configuring a smarthost for sendmail
To configure a smarthost (with authentication) for sendmail, you'll have to create a file called /etc/mail/auth/client-info and modify the file /etc/mail/sendmail.mc.
Configure authentication
Create the directory /etc/mail/auth/ if it doesn't exist. Then create the file /etc/mail/auth/client-info. The content in of this file represents your login credentials for the smarthost. It should look like the example below:
AuthInfo: "U:username" "I:email" "P:password"
Where:
- is the fully qualified domain name (fqdn) of your smarthost
- is the userid used to login at the smarthost (often your email address)
- is the account to be used for your smarthost (often your email address as well)
- is the password that belongs to your smarthost username
Here is an Auth File example: client-info.zip
Next, you'll have to build the password hash database with this command:
sudo bash -c "cd /etc/mail/auth/ && makemap hash client-info <> Configure sendmail
Now you have prepared the authentication setup for the concerning smarthost,
let's go on and configure sendmail to use this smarthost. To do so, please edit the
file /etc/mail/sendmail.mc. Find the line starting with MAILER_DEFINITIONS in this
file and insert the lines before this line:
define(`SMART_HOST',`relay:smtp.yourisp.com')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
I also had to add these lines to get mine to work (not part of the original article).
# "Smart" relay host (may be null)
define(`RELAY_MAILER_ARGS',`TCP $h 587')dnl
DSsmtp.smarthost.net
The key addition that I made to the article is the DS entry. Without this entry, the actual
forwarding did now work.
Now use the M4 macro processor to translate the /etc/mail/sendmail.mc file into a format
sendmail understands (/etc/mail/sendmail.cf). This can be taken out by:
sudo bash -c "cd /etc/mail/ && m4 sendmail.mc > sendmail.cf"
This is an example of what mine looks like. I use it to effectively relay all sendmail delivery
via my isp's authenticated smarthost on port 587. You can use webmin to effectively copy and
paste this. I am also including a zip file, but you would have to search through it extensively
- I don't recommend it.
divert(-1)dnl
divert(0)dnl
define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail.mc, v 8.14.1-8ubuntu1 2007-08-01 05:06:30 cowboy Exp $')dn1
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
undefine(`confHOST_STATUS_DIRECTORY')dnl #DAEMON_HOSTSTATS=
FEATURE(`no_default_msa')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Name=MTAv4,Port=smtp,Family=inet')
DAEMON_OPTIONS(`Name=MSPv4,Port=submission,Family=inet')
define(`confPRIVACY_FLAGS', `authwarnings,needmailhelo,noexpn,novrfy')dnl
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')dnl
FEATURE(`access_db', , `skip')dnl
FEATURE(`relay_hosts_only')dnl
FEATURE(`use_cw_file')dnl
FEATURE(`greet_pause', `1000')dnl
FEATURE(`delay_checks', `friend', `n')dnl
define(`confBAD_RCPT_THROTTLE',`3')dnl
FEATURE(`conncontrol', `nodelay', `terminate')dnl
FEATURE(`ratecontrol', `nodelay', `terminate')dnl
dnl define(`confCON_EXPENSIVE',`True')dnl
include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl
FEATURE(`relay_hosts_only')dnl
define(`RELAY_MAILER_ARGS',`TCP $h 587')dnl
define(`SMART_HOST',`relay:smtp.smarthost.net')dnl
# "Smart" relay host (may be null)
DSsmtp.smarthost.net
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
FEATURE(`always_add_domain')dnl
MASQUERADE_AS(`yourdomain.net')dnl
GENERICS_DOMAIN(`yourdomain.net')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
MAILER(`local')dnl
MAILER(`smtp')dnl
here is an example config file
Note: What to do if no authentication needed?
In case no authentication is needed or necessary in your smarthost setup.
This how-to can be used as well. In that case, just simply skip the paragraph
Configure authentication and only add the line define(`SMART_HOST', )dnl
to the /etc/mail/sendmail.mc file. All the rest of the how-to applies as well.
To prevent sendmail from sending messages for local recipients through the smarthost,
you'll have to tell sendmail which domains are locally processed. This can be done by
inserting all local domains in the file /etc/mail/local-host-names, like in the example below:
localhost
mylocaldomain.com
myotherlocaldomain.com
Of course, the domains mylocaldomain.com and myotherlocaldomain.com need
to be replaced by your actual local domains.
Now, again this file /etc/mail/local-host-names needs to be translated into a format
sendmail understands. Us the make command to do so, like shown below:
sudo bash -c "cd /etc/mail && make"
Restart sendmail and check the configuration
To make sure your configuration is all right, restart sendmail
To restart sendmail, use this command:
sudo /etc/init.d/sendmail restart
sudo bash -c "cd /etc/mail/auth/ && makemap hash client-info <>
sudo bash -c "cd /etc/mail/ && m4 sendmail.mc > sendmail.cf"
/etc/init.d/sendmail reload
this solved the following problems for me
Apr 13 23:20:07 ubu sendmail[8640]: m3E6K5Rq008640: from=, size=1221, class=0, nrcpts=1, msgid=<027201c89db4$0287afa0$6402a8c0@experience>, proto=SMTP, daemon=MTAv4, relay=[192.168.2.100]
Apr 13 23:20:07 ubu sendmail[8659]: m3E6K5Rq008640: to=, ctladdr= (1000/1000), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=121221, relay=64.202.165.58, dsn=5.1.2, stat=Host unknown (Name server: 64.202.165.58: host not found)
(reason: 550 Host unknown)
550 5.1.2
Host unknown (Name server: 64.202.165.58: host not found)
Host unknown (Name server: 64.202.165.58: host not found)
If you have gone through all of this and you still cannot figure out what is wrong, try going to your /etc folder and find nswitch.conf
this is what mine looks like:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
#hosts: dns files mdns4_minimal mdns4 [NOTFOUND=return]
passwd: compat
group: compat
shadow: compat
hosts: dns [NOTFOUND=continue] files
ipnodes: dns [NOTFOUND=continue] fileshosts: dns [NOTFOUND=continue] files
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
and your /etc/resolv.conf file should look like (with your own nameservers/dns servers)
nameserver 68.87.69.146
nameserver 68.87.85.98
nameserver 192.168.2.1
sendmail.zip
Labels: alternate, authenticate, authentication, debian, host not found, host unknown, isp, port, relay, sendmail, smarthost, smtp, ubuntu