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&#8217;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">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; define(`SMART_HOST\', `your-smtp-server\')<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FEATURE(authinfo)dnl
    </div>
  </td>
</tr>
1

Note: Please note, that these are &#8221;oriented&#8221; 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">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
    </div>
  </td>
</tr>
1
  <td>
    <div class="text codecolorer">
      &nbsp;
    </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">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makemap hash /etc/mail/authinfo < /etc/mail/authinfo
    </div>
  </td>
</tr>
1

and finally restart sendmail:

  <td>
    <div class="text codecolorer">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /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">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # /etc/mail/userdb <br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sven:mailname sven@foo.org
    </div>
  </td>
</tr>
1

Finally create the corresponding database:

  <td>
    <div class="text codecolorer">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makemap btree /etc/mail/userdb.db < /etc/mail/userdb
    </div>
  </td>
</tr>
1

… and finally restart sendmail:

  <td>
    <div class="text codecolorer">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /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">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /usr/sbin/sendmail -bv root@localhost
    </div>
  </td>
</tr>
1

Should show a &#8221;local&#8221; delivery.

  <td>
    <div class="text codecolorer">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /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

Tags: Linux sendmail

author

Authored By Amit Agarwal

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

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it