Wednesday, September 7, 2011

How to send one mail to "relay server"(another mail server) using sendmail?

■ Requirement : sending mail to another relay server using sendmail.
■ OS Environment : Linux, RHEL, Centos
■ Implementation Steps : 

1. edit /etc/mail/sendmail.mc & add this line :

define(`SMART_HOST',`[smarthost.example.net]')dnl

3. Rebuild the sendmail.cf :

$ m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

4.Restart sendmail:

$ /etc/rc.d/init.d/sendmail restart

5. Now send mail and check the maillog. Log will show relay name.

sendmail without DNS :

There are a number of steps required to successfully use sendmail when there is limited or no DNS.

1. I assume that domain is resolvable, either by /etc/hosts or DNS, or alternatively we can specify an IP address.
2. Set realy host in /etc/mail/sendmail.mc ie define(`SMART_HOST',`name.of.smart.host')dnl
3. Since the system implicitly have limited resolving capabilities, accept email for unknown domains so use line in /etc/mail/sendmail.mc of the form
FEATURE(accept_unresolvable_domains)dnl
4. We have to make it sure that the ServiceSwitchFile (by default at /etc/mail/service.switch) has content similar to:

aliases files
hosts files

5. Setting the submission agent to ignore DNS. Use line in /etc/mail/submit.mc of the form

define(`confDIRECT_SUBMISSION_MODIFIERS',`C')

6. Use line in /etc/mail/submit.mc of the form

FEATURE(accept_unresolvable_domains)dnl

7. Execute :

$m4 /etc/mail/submit.mc > /etc/mail/submit.cf

6.service sendmail restart

No comments:

Post a Comment