Linux上配置sendmail

How to config sendmail to send mail in Linux

It will describe how to config sendmail to send mail to XX smtp server.

Test Env:

$ uname -a Linux smcfrd64 2.6.18-128.el5 #1 SMP Wed Dec 17 11:42:39 EST 2008 i686 i686 i386 GNU/Linux

Linux computer IP: 16.186.77.7

pre-condition: DNS is set up. Package sendmail and sendmail-cf should be installed.

1. Config the host name of the linux server

Check the file /etc/hosts, make sure that the loopback IP 127.0.0.1 is configed in the first line and the NIC IP is configed with the format [IP shortname FQDN name with domain]. If no, please add them manually.The FQDN name with domain is necessary for sendmail. Refer to the valid file content as follow.

127.0.0.1 localhost.localdomain localhost

::1 localhost6.localdomain6 localhost6

16.157.128.106 ux14231

16.157.128.127 ux14229

16.186.77.7 smcfrd64 smcfrd64.localdomain.com'

You can try the command below to check whether the hostname is configed correctly.

$host smcfrd64.localdomain.com

2. Check whether sendmail service is started

$ sudo service sendmail status

if it is running, then stop it.

$ sudo service sendmail stop

3. Config sendmail

1) Edit the file /etc/mail/sendmail.mc

Uncomment the definition SMART_HOST and add the correspondign FEATURE to it:

                          define(`SMART_HOST', `[smtp.xx.com.]')dnl

                           FEATURE(`authinfo',`hash /etc/mail/authinfo.db')dnl

2) Run m4 command to generate new sendmail.cf

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

If you don't log on as root, you will fail to run this command even using sudo. You can run it in an alternative way.

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

$sudo cp /tmp/sendmail.cf .

3) Edit/create the file /etc/mail/authinfo, add the follow line, containing your smtp server, mail account and password:

AuthInfo:smtp.xx.com "U:domain.com@noip-smtp" "P:*******"

4) Map the authinfo file

$makemap hash /etc/mail/authinfo < /etc/mail/authinfo

4. Start the sendmail service. You can read the file in /var/log/maillog to see whether thesendmail starts successfully. You can also run the command below to test it:

$echo "test van Brunöö, this is één mail"|mail -s "test éne mail" XXX@hp.com


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值