Enter your email address:

Delivered by FeedBurner

Smarthost for sendmail and/or exim


StumbleUpon Toolbar

This will describe you how to set up a smarthost using either sendmail or exim, for the exim,
i will only consider Debian.

This is to send emails using your linux server as your smtp server, and it will use your ISP email server to send all your emails through it, to the final users.

The sendmail configuration I have tested on CentOS, and Fedora, but should work on Debian
and Ubuntu as well

Sendmail

You need sendmail 8.11 or a later one to do this.

sendmail.mc

Edit with your favorite text editor the file /etc/mail/sendmail.mc and add this line
dnl define(`SMART_HOST',`smtpserver.domain.xxx')
[change smtpserver.domain.xxx for your ISP server or any server that is open
for you.
Now generate the sendmai.cf file, for that use this command

make -C /etc/mail

Here you can check my sendmail.mc file, just change the lines in bold, to fit your needs

divert(-1)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for Red Hat Linux')dnl
OSTYPE(`linux')dnl
define(`confDEF_USER_ID',``8:12'')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
define(`confTO_IDENT', `0')dnl
FEATURE(`no_default_msa',`dnl')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -T -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
FEATURE(`accept_unresolvable_domains')dnl
LOCAL_DOMAIN(`localhost.localdomain')dnl
dnl MASQUERADE_AS('your.domain')dnl
FEATURE(`access_db')dnl
FEATURE(`authinfo', `hash /etc/mail/authinfo')
define(`SMART_HOST',`your.smtp.server')dnl
MASQUERADE_AS(your.domain)dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

The italics/bold lines are needed to avoid your email being rejected because the name
could not be resolved.

Create a file named
/etc/mail/genericstable
with this inside it

root	user@domain.com

and the execute this,

makemap hash /etc/mail/genericstable < /etc/mail/genericstable

In this example we are supposing you need to authenticate to the email server of your ISP

so be sure to have this line in your

/etc/mail/sendmail.mc

FEATURE(`authinfo', `hash /etc/mail/authinfo')

and also create this file:

vi /etc/mail/authinfo

with this inside

AuthInfo:your.smtp.server "U:user@your.smtp.server" "I:user" "P:passwd" "M:LOGIN PLAIN"

and run

makemap hash /etc/mail/authinfo < /etc/mail/authinfo

and make authinfo readable only by root

chmod 600 /etc/mail/authinfo

Now you are done, you can start sending emails using your ISP account with your linux server.

Exim

This have only tested with Debian by me, and it is really easy.

run

dpkg-reconfigure exim4

and choose smarthost, and provide with the name and port of your ISP server, after that, edit
the file

/etc/exim4/passwd.client

and insert your user and password info, to authenticate on your ISP server in this format

target.mail.server.example:login:password

You are done!

Trackback URL for this post:

http://www.go2linux.org/trackback/35
StumbleUpon Toolbar

 If you like this article, subscribe to our full rss

If this article was somehow useful for you, you can leave something in the tip's jar

Please post your question in our forum and use comments only to leave your comments about the article, thanks.

Thanks very much. Got my

Thanks very much. Got my Debian box mailing nicely. :)

dynamic ip First of all, got

dynamic ip

First of all, got it working, THANKS you are my hero :-). I just want to mention that some smarthosts (smtp.1und1.de) will check your domain. So you need to use a DynDns account as your domain name.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

This site is proudly hosted at Bluefur Hosting