Configure Sendmail on CentOS

Configure Sendmail on CnetOS
1. Locate and edit the sendmail.mc file at /etc/mail

[sourcecode language="bash"]
vim /etc/mail/sendmail.mc
[/sourcecode]

Uncomment these lines from the default config by removing the dnl and the space from in front of the line.

[sourcecode language="text"]
define(`confTO_QUEUEWARN', `4h')dnl
define(`confTO_QUEUERETURN', `5d')dnl
FEATURE(delay_checks)dnl
define(`confSMTP_LOGIN_MSG', `$j server ready at $b')dnl
[/sourcecode]

And comment this line by adding the dnl in front of the line:

[sourcecode language="text"]
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
[/sourcecode]

add the following line in it’s place to allow the server to accept connections from outside, so in the end it looks like this:

[sourcecode language="text"]
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
[/sourcecode]

2. Create the sendmail.cf file
From the /etc/mail directory, you can backup the current and then create the new sendmail.cf like this:

[sourcecode language="bash"]
cd /etc/mail
cp sendmail.cf sendmail.cf_`date +%m%d%y_%H%M%S`
m4 sendmail.mc > sendmail.cf
#view the m4 output
m4 sendmail.mc
[/sourcecode]

3. Configure the /etc/mail/local-host-names file

[sourcecode language="bash"]
vim local-host-names
#add your domain name into this file
real.domain.name
[/sourcecode]

4. Configure the /etc/mail/virtusertable file to receive emails

[sourcecode language="bash"]
admin@real.domain.name        real_email_address
[/sourcecode]

5. Build the database or hash of the file by using the following command

[sourcecode language="bash"]
makemap hash virtusertable < virtusertable
[/sourcecode]

6. start/restart the mail server

[sourcecode language="bash"]
/etc/init.d/sendmail restart
[/sourcecode]

Question and solutions:

[sourcecode language="bash"]
Q: How to install sendmail
A: $ sudo yum install sendmail sendmail-cf
Q: cannot open `/usr/share/sendmail-cf/m4/cf.m4'
A: You need to install the sendmail-cf package. $ sudo yum install sendmail-cf
Q: NONE:0: m4: ERROR: end of file in argument list while you were using the m4 sendmail.mc &amp;gt; sendmail.cf
A: check the quotations in sendmail.mc file, particularly the sentence you added, to make sure that the quotation is ` and ‘, since m4 expects back-tick - tick quoting (`xxx')
Q:sending mail as localhost.localdomain?
A: Modify HOSTNAME in the /etc/sysconfig/network file to
HOSTNAME=real.hostname.com
[/sourcecode]

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...