Smarthost for sendmail and/or exim
Follow @ggarronThis 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 commandmake -C /etc/mail
Here you can check my sendmail.mc file, just change the lines in bold, to fit your needsdivert(-1)dnl include(`/usr/share/sendmail-cf/m4/cf.m4')dnlThe 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
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
root user@domain.comand 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 insideAuthInfo: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 rootchmod 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. rundpkg-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 formattarget.mail.server.example:login:passwordYou are done!