Configure sendmail for SMTP relay with your ISP
2009-09-26
709 words
4 mins read
http://cri.ch/linux/docs/sk0009.html
I have copied the document from the above link without modifications
Author: Sven Knispel
Updated: 05-01-2005
Feedback welcome: <a href="mailto:linux@cri.ch">linux@cri.ch
Free service provided by: <a set="yes" linkindex="2" href="http://cri.ch/">www.cri.ch
The following article explains the setup of sendmail for forwarding mails to your ISP’s smtp server.
It is assumed that you have sendmail up-to-date and configured properly.
_Note: this setup does not work properly for smtp-server using
<td>
<div class="text codecolorer">
SASL
</div>
</td>
</tr>
1
|
(e.g. like
<td>
<div class="text codecolorer">
smtp.pobox.com
</div>
</td>
</tr>
1
|
)
Most of the commands must be executed with the corresponding rights (using
<td>
<div class="text codecolorer">
sudo
</div>
</td>
</tr>
1
|
).
1. configure your smtp-server
(this requires that you have the package
<td>
<div class="text codecolorer">
sendmail-cf
</div>
</td>
</tr>
1
|
installed)
1.1. changes to
<td>
<div class="text codecolorer">
/etc/mail/sendmail.mc
</div>
</td>
</tr>
1
|
Uncomment the definition
<td>
<div class="text codecolorer">
SMART_HOST
</div>
</td>
</tr>
1
|
and add the correspondign
<td>
<div class="text codecolorer">
FEATURE
</div>
</td>
</tr>
1
|
to it:
<td>
<div class="text codecolorer">
define(`SMART_HOST\', `your-smtp-server\')<br /> FEATURE(authinfo)dnl
</div>
</td>
</tr>
1
|
Note: Please note, that these are ”oriented” quotes.
1.2. create the new
<td>
<div class="text codecolorer">
sendmail.cf
</div>
</td>
</tr>
1
|
Stop sendmail by issuing the command
<td>
<div class="text codecolorer">
/sbin/service sendmail stop
</div>
</td>
</tr>
1
|
and log on as
<td>
<div class="text codecolorer">
root
</div>
</td>
</tr>
1
|
to issue this command.
<td>
<div class="text codecolorer">
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
</div>
</td>
</tr>
1
|
<td>
<div class="text codecolorer">
</div>
</td>
</tr>
1
|
1.3. Define the account information for connecting to the smtp-server
Edit/create
<td>
<div class="text codecolorer">
/etc/mail/authinfo
</div>
</td>
</tr>
1
|
and add the following line:
<td>
<div class="text codecolorer">
AuthInfo:<your-smtp-server> "U:<your-smtp-user>" "P:<your-smtp-password>" "M:DIGEST-MD5"
</div>
</td>
</tr>
1
|
_Note:_The
<td>
<div class="text codecolorer">
M:
</div>
</td>
</tr>
1
|
may vary depending on the capabilities of the smtp-server (e.g.
<td>
<div class="text codecolorer">
CRAM-MD5, PLAIN
</div>
</td>
</tr>
1
|
).
Create
<td>
<div class="text codecolorer">
authinfo.db
</div>
</td>
</tr>
1
|
:
<td>
<div class="text codecolorer">
makemap hash /etc/mail/authinfo < /etc/mail/authinfo
</div>
</td>
</tr>
1
|
and finally restart sendmail:
<td>
<div class="text codecolorer">
/sbin/service sendmail restart
</div>
</td>
</tr>
1
|
1.4. Configure header rewriting (optional)
Header rewriting consists in replacing the
<td>
<div class="text codecolorer">
From:
</div>
</td>
</tr>
1
|
and
<td>
<div class="text codecolorer">
Reply to:
</div>
</td>
</tr>
1
|
in the header of an outgoing mail in order for the recipient to reply to a valid address.
This can be set by editing the file
<td>
<div class="text codecolorer">
/etc/mail/userdb
</div>
</td>
</tr>
1
|
:
<td>
<div class="text codecolorer">
<local-name>:mailname <email-adsress>
</div>
</td>
</tr>
1
|
E.g.:
<td>
<div class="text codecolorer">
# /etc/mail/userdb <br /> sven:mailname sven@foo.org
</div>
</td>
</tr>
1
|
Finally create the corresponding database:
<td>
<div class="text codecolorer">
makemap btree /etc/mail/userdb.db < /etc/mail/userdb
</div>
</td>
</tr>
1
|
… and finally restart sendmail:
<td>
<div class="text codecolorer">
/sbin/service sendmail restart
</div>
</td>
</tr>
1
|
1.5. Test your settings
Issue following commands and check the trace for verifying the delivery path:
<td>
<div class="text codecolorer">
/usr/sbin/sendmail -bv root@localhost
</div>
</td>
</tr>
1
|
Should show a ”local” delivery.
<td>
<div class="text codecolorer">
/usr/sbin/sendmail -bv <your-mail>@<your-domain>
</div>
</td>
</tr>
1
|
Should show a delivery path through your ISP.
For troubleshooting you should check the mail-log:
<td>
<div class="text codecolorer">
/var/log/maillog
</div>
</td>
</tr>
1
|
2. Forwarding
Forward can be defined in
<td>
<div class="text codecolorer">
~/.forward
</div>
</td>
</tr>
1
|
. (just enter the e-mail addressto forward to). _Note:_The permissions of that file must be adjusted correspondingly in order to avoid sendmail ignoring it (see
<td>
<div class="text codecolorer">
/var/log/maillog
</div>
</td>
</tr>
1
|
in case of problems).
3. References
For further information I recommend to check following link:
- <a linkindex="3" href="http://www.pl-berichte.de/work/server/mailserver.html">http://www.pl-berichte.de/work/server/mailserver.html
- <a linkindex="4" href="http://www.sendmail.org/%7Eca/email/auth.html">http://www.sendmail.org/~ca/email/auth.html
Related Articles:
- 2009/09/26 Script to generate a html file with link to all files in directory
- 2009/09/17 top command with rc to make it more useful and beautiful.
- 2009/09/17 Diff Linux command — Find the difference in files the easier way.
- 2009/08/12 Consider your account to be for you then use Linux
- 2009/07/20 bash tutorial for begineer and experienced.

Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.